Rewrite but still shows index/

Discussion in 'Apache' started by HighRankingSEO, Oct 22, 2009.

  1. #1
    Hey, right now I have this in my htaccess to strip .php file extension
    
    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)\.php\ HTTP/ [NC]
    RewriteRule .+ http://www.websiteconsultants.org/%1 [R=301,QSA]
    
    Code (markup):



    ...although I am having one issue, the index.php file now becomes index...I would like the hp to just be http://www.websiteconsultants.org and not
    http://www.websiteconsultants.org/index

    I tried to 301 it like this....but it didnt work:
    Redirect 301 /index http://www.websiteconsultants.org


    How do I remove the /index ?
     
    HighRankingSEO, Oct 22, 2009 IP
  2. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Put the rule before it to redirect index.php and use [L] so it stops processing before the next rule.

    RewriteEngine On
    
    RewriteRule ^index\.php$ / [R=301,L]
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)\.php\ HTTP/ [NC]
    RewriteRule .+ http://www.websiteconsultants.org/%1 [R=301,QSA]
    Code (markup):
     
    chadsmith, Oct 26, 2009 IP
  3. HighRankingSEO

    HighRankingSEO Well-Known Member

    Messages:
    423
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    125
    #3
    Thanks by the way, that was helpful. Usually I just 301'd it but it didn't work in this instance. Thanks again for the fix.
     
    HighRankingSEO, Feb 20, 2010 IP