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]
link|improve this question
Please post your apache configuration file. – Steven Mar 10 '11 at 1:31
look at the edit – MohamedKadri Mar 10 '11 at 1:38
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
feedback

3 Answers

  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.

link|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
feedback

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.

link|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
feedback

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 ;)

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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