Home > SEO > Mod Rewrite Rules for Uniform Spidering

Mod Rewrite Rules for Uniform Spidering

September 14th, 2007

I mention in my earlier post that you should choose to use www or not , but regardless, stick with it. Another issue that arises is that you can’t always control how someone else will link to your site. While most will include www. others wil not. To insure that all you links are cataloged in the search engines uniformly, you should implement a couple of rules in your .htaccess file.

  1. A rule to insure www is (or is not) always used.
    To Redirect mysite.com to www.mysite.com
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
         
    To Redirect www.mysite.com to mysite.com
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.domain\.com$ [NC]
    RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
        
  2. A rule to always redirect your home page (index.html, index.php, default.htm, etc) to just root (http://www.yourwebsite.com/)
    REDIRECT 301 "index.htm" http://www.somewebsite.com

     

Thers is a good guide on mod rewrite here  at the source.

While it won’t apply to most of the people reading this blog, it is also important not to have multiple views of the same information. So if you have a site with a page of toasters and you give the browser the option to sort by price, color, etc, be sure that the spiders only see one sort of the information.

SEO , , ,

You must be logged in to post a comment.