Resolving canonical issue on Apache server

Filed under: by: Keym4k3r

One of possible ways of doing it is to add to htaccess file following lines :

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain\.com [nc]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

The above redirect all the requests to domain.com
to www.domain.com
If you want rediredt www version to the one without, then the code is:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.domain\.com [nc]
RewriteRule (.*) http://domain.com/$1 [R=301,L]

0 comments: