/ Published in: Apache
Rrewrite "www.domain.com -> domain.com" and viceversa
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines. #RewriteCond %{HTTPS} !=on #RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] #RewriteRule ^(.*)$ http://%1/$1 [R=301,L] # Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines. #RewriteCond %{HTTPS} !=on #RewriteCond %{HTTP_HOST} !^www\..+$ [NC] #RewriteCond %{HTTP_HOST} (.+)$ [NC] #RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L] #common configuration <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^website\.it RewriteRule ^(.*)$ http://www.website.it/$1 [R=301,L] </IfModule>