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

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

1 Answer 1

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.