Redirect
Using cPanel
If your website is hosted with a
provider that uses cPanel, you can even set up your redirects without touching
a line of code. This actually adds the redirect rule directly to the .htaccess
file, but sometimes I’d rather not get my hands dirty. To do this, log in to
your cPanel, and go to Redirects.
Redirect non-WWW to WWW:
Redirect Using .htaccess
If your site is hosted on Apache, you can redirect from the WWW to the non-WWW, or vice versa, with a few lines in your .htaccess file.Redirect WWW to non-WWW:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(yourdomain\.com)?$
RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L]
Redirect non-WWW to WWW:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.yourdomain\.com)?$
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
Google
Webmaster Tools
If you’ve verified your site with
Google Webmaster Tools, you can set your preferred domain by going to Site
Configuration > Settings, and selecting either ‘Display URLs as
www.yourdomain.com’ or ‘Display URLs as yourdomain.com’.
This will make sure that Google only
indexes your preferred canonical URL. However, it doesn’t fix the problem of
splitting your link juice so you should still set up a redirect using one of
the following methods.
No comments:
Post a Comment