Posted By

macodev on 10/04/11


Tagged

http remove htaccess www rewrite


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

localsearchguy


.htaccess add/remove www to domain redirect


 / Published in: Apache
 

Rrewrite "www.domain.com -> domain.com" and viceversa

  1. # Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines.
  2. #RewriteCond %{HTTPS} !=on
  3. #RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  4. #RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
  5.  
  6. # Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines.
  7. #RewriteCond %{HTTPS} !=on
  8. #RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
  9. #RewriteCond %{HTTP_HOST} (.+)$ [NC]
  10. #RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
  11.  
  12. #common configuration
  13. <IfModule mod_rewrite.c>
  14. Options +FollowSymLinks
  15. RewriteEngine on
  16. RewriteCond %{HTTP_HOST} ^website\.it
  17. RewriteRule ^(.*)$ http://www.website.it/$1 [R=301,L]
  18. </IfModule>

Report this snippet  

You need to login to post a comment.