Using 301 Redirects for Canonical Issue

Discussion in 'Site & Server Administration' started by leaseman, Nov 14, 2010.

  1. #1
    I current have the following code in my htaccess file to fix the non-www to the www issue:

    RewriteEngine on
    rewritecond %{http_host} ^capitalsolutionsonline.net [nc]
    rewriterule ^(.*)$ http://www.capitalsolutionsonline.net/$1 [r=301,nc]

    This works fine.

    What I still need to do is redirect www.capitalsolutionsonline.net/index.html to www.capitalsolutionsonline.net/

    This in attempt to fix an apparent canonical issue

    What code to I need to add to the htaccess file to do this.

    Thanks if advance!
     
    leaseman, Nov 14, 2010 IP
  2. imocoder

    imocoder Member

    Messages:
    45
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    As soon as your directory index is index.html you are going into an endless loop if you do so.
    In my view the simplest solution is to add this line into the heade of index.html
    
    <link rel="canonical" href="www.capitalsolutionsonline.net"/>
    
    HTML:
    In this way index.html won't be considered.
     
    imocoder, Nov 15, 2010 IP