Posted By

ginoplusio on 05/03/10


Tagged

modrewrite htaccess www


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

JCFreak1223
benediktvaldez


Add and remove www to urls through .htaccess


 / Published in: Other
 

URL: http://www.barattalo.it/2010/05/02/10-htaccess-usefull-tips/

Add and remove www to urls through .htaccess with mod_rewrite

  1. # add www to any url
  2. RewriteEngine on
  3. RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
  4. RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
  5.  
  6.  
  7. # remove www from any url
  8. Options +FollowSymlinks
  9. RewriteEngine on
  10. RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
  11. RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

Report this snippet  

You need to login to post a comment.