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 http://www.domain.com is the same as http://domain.com, you will be sent to the same page but they will have different URLs.

For SEO if a search engine saw http://www.domain.com it will crawl this page, check the content and index the content. Then later if it goes and crawls http://domain.com 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 example.com with your domain.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$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]

1 comment:

  1. SAP MM,SD, real Time Training in Chennai
    We provides Best SAP MM,SD Training in Chennai wih real time project assistance by our leading Materail Management Consultant.
    For Free Live Demo @ Call to 8122241286.
    www.thecreatingexperts.com
    SAP MM
    SAP SD

    ReplyDelete

GitHub repository using Git Bash command

  To add a project to a GitHub repository using Git Bash command line, you can follow these steps: Create a new repository on GitHub by logg...