Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have created a subdomain for my website (fr.mohamedkadri.com) and after 24 hours it became active but it redirects to the subfolder that I poited to (mohamedkadri.com/fr)

Is there a problem? why the subdomain redirects to the subfolder?

here is my .htaccess:

SetEnv PHP_VER 5

RewriteEngine On

RewriteCond %{HTTP_HOST} !^mohamedkadri.com$ [NC]
RewriteRule ^(.*)$ http://mohamedkadri.com/$1 [L,R=301]
share|improve this question
    
so the problem is in the htaccess! but how to make it enforce the url without www and keep other subdomains? –  MohamedKadri Mar 10 '11 at 1:40

3 Answers 3

  1. You could add a more rewrite conditions

    RewriteCond %{HTTP_HOST} !^mohamedkadri.com$ [NC]

    RewriteCond %{HTTP_HOST} !^fr.mohamedkadri.com$ [NC]

    RewriteRule ^(.*)$ http://mohamedkadri.com/$1 [L,R=301]

  2. You could setup apache virtual hosts, so each domain would have its own configuration.

share|improve this answer
    
Thanks for your answer, I think its a good solution but I got a simpler way. –  MohamedKadri Mar 10 '11 at 1:51
    
The answers do the same thing in different ways: Your's leaves everything alone but www.mohamedkadri.com. Mine redirects everything to mohamedkadri.com except for fr.mohamedkadri.com. Depending on your goal, either one could be best. –  Steven Mar 10 '11 at 1:53

afaik subdomains are stored in subfolders (e.g. apache). as long as you can reach your target via the intended fr.mohamedkadri.com/and/more/URL where is the problem?

Edit0: Imho you have to use rewrite rules (apache mod_rewrite) in your .htaccess file in the folder named according to your subdomain.

share|improve this answer
    
the problem is that when I write fr.mohamedkadri.com I get mohamedkadri.com/fr/, the subfolder that the subdomain "fr" is pointing to –  MohamedKadri Mar 10 '11 at 1:14
    
so a larger url must be like fr.mohamedkadri.com/anything-else and not mohamedkadri.com/fr/anyting-else –  MohamedKadri Mar 10 '11 at 1:16

Ok I got the point!

I eidted my htaccess file:

RewriteCond %{HTTP_HOST} !^mohamedkadri.com$ [NC] RewriteRule ^(.*)$

to

RewriteCond %{HTTP_HOST} www.mohamedkadri.com$ [NC] RewriteRule ^(.*)$

So I got the www removed and other subdomains kept as is!

Thanks for your replies ;)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.