If you want to redirect http://www.example.com to http://example.com, you can use this:RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteRule ^/?$ "http\:\/\/example\.com\/" [R=301,L]- If you want to redirect http://example.com to http://www.example.com, you can use this:RewriteCond %{HTTP_HOST} !^www.example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Monday, March 9, 2015
- Posted By: Unknown
- Comments: 14 comments
Redirect (301) for website homepage
Monday, January 19, 2015
- Posted By: Unknown
- Comments: No comments
htaccess file code
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sitename.com [NC]
RewriteRule ^(.*)$ http://www.sitename.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^sitename.com [NC]
RewriteRule ^(.*)$ http://www.sitename.com/$1 [L,R=301]