.htaccess redirect help

Discussion in 'Apache' started by bpatrick, Aug 17, 2009.

  1. #1
    Hi,
    I had some of my urls indexed in google search engine incorrectly. For example google indexed this url

    http://www.somedomain.com/category/123/

    when correct url was

    http://www.somedomain.com/category/123/index.html

    When visitors click on these incorrect urls they are taken to the home page instead of the category page.

    How can I setup a redirect on my htaccess file for all urls ending with the pattern /category/(*.)/$ to /category/(*.)/index.html

    I have the following entry in the .htaccess file
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^(.*)$ index.php [QSA,L]
    </IfModule>


    Thanks
    Patrick
     
    bpatrick, Aug 17, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteRule ^category/(.*)/$ http://www.example.com/category/$1/index.html [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^(.*)$ index.php [QSA,L]
    </IfModule>
    
    Code (markup):
     
    premiumscripts, Aug 17, 2009 IP