Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 want to redirect to the very same url without the WWW prefix, how can I achieve this?


share|improve this question
I've tried this: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] , it won't work for me. – user57256 Oct 15 '10 at 14:32
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

of if you prefer this one:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

The RewriteCond means that if the domain starts with www then it will be redirected to

share|improve this answer
it's not working for me, I have to say, the is th emirrored version of my site under , any idea what I could try here?`thx – user57256 Oct 17 '10 at 15:30
@user57256 can you post your current virtualhost servername and serveralias configuration and if they are in different virtualhosts, if their documentroot is the same, so i can provide you with a more accurated answer ? – Guapo Oct 17 '10 at 15:49

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.