Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a subdomain for my website ( and after 24 hours it became active but it redirects to the subfolder that I poited to (

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

here is my .htaccess:

SetEnv PHP_VER 5

RewriteEngine On

RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^(.*)$$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
  1. You could add a more rewrite conditions

    RewriteCond %{HTTP_HOST} !^$ [NC]

    RewriteCond %{HTTP_HOST} !^$ [NC]

    RewriteRule ^(.*)$$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 Mine redirects everything to except for 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 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 I get, the subfolder that the subdomain "fr" is pointing to – MohamedKadri Mar 10 '11 at 1:14
so a larger url must be like and not – MohamedKadri Mar 10 '11 at 1:16

Ok I got the point!

I eidted my htaccess file:

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


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

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

Thanks for your replies ;)

share|improve this answer

Your Answer


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.