Hello,
I am trying to push my server to return Moved Permanently code and redirect these URLs to the main URL, but cant find the right code.
domain.com
w.domain.com
ww.domain.com
wwww.domain.com
to
www.domain.com
There are a number of codes available on the net and all supposed to do that, but which one is the eight one?
1)
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewritecond %{http_host} ^w.domain.com [nc]
rewritecond %{http_host} ^ww.domain.com [nc]
rewritecond %{http_host} ^wwww.domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
2)
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteCond %{HTTP_HOST} ^w.example\.com
RewriteCond %{HTTP_HOST} ^ww.example\.com
RewriteCond %{HTTP_HOST} ^wwww.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
3)
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^w.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^ww.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^wwww.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]