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 want to redirect http://www.mydomain.com/subfolder/index.php to the very same url without the WWW prefix, how can I achieve this?

Thanks

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
add comment

1 Answer

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com$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 mydomain.com.

share|improve this answer
    
it's not working for me, I have to say, the www.mysite.com is th emirrored version of my site under mydomain.com , 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
add comment

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.