Saturday, May 9, 2015

.htaccess To Redirect URLs WWW

For SEO it is important to use a set standard of how you present your domain. The most popular approach is to use the sub-domain www. Many people don't know this but is the same as, you will be sent to the same page but they will have different URLs.

For SEO if a search engine saw it will crawl this page, check the content and index the content. Then later if it goes and crawls the search engines will see the same content but on different URLs and think it is duplicate content and therefore will penalize this domain in the search engine ranking.

.htaccess To Redirect URLs
To use htaccess to redirect URL just copy and paste the snippet below and replace with your domain.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$$1 [L,R=301,NC]

Add www With HTTP/HTTPS

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


Related Posts Plugin for WordPress, Blogger...