301 and Mod_rewrite conflicting

Discussion in 'Apache' started by cagintranet, May 12, 2006.

  1. #1
    Ok, i followed Nintendo's mod_rewrite sticky post - and it worked flawlessly on my directory until i also tried to do a 301 redirect on certain pages within the directory.

    Now i think Google may be punishing me for it because ive lost a lot of indexed pages and some weird URLs are starting to show up in Yahoo.

    Here is the code for my .htaccess:
    
    AddType application/x-httpd-php .xml
    
    Redirect permanent /directory/335.php http://pghsource.cagintranet.com/directory/114.php
    Redirect permanent /directory/317.php http://pghsource.cagintranet.com/directory/70.php
    Redirect permanent /directory/320.php http://pghsource.cagintranet.com/directory/310.php
    Redirect permanent /directory/316.php http://pghsource.cagintranet.com/directory/118.php
    Redirect permanent /directory/339.php http://pghsource.cagintranet.com/directory/121.php
    
    
    Options +Indexes
    
    RewriteEngine on
    RewriteRule ^([0-9]+)/([0-9]+).php$ http://pghsource.cagintranet.com/directory/index.php?c=$2&s=$1 [L]
    RewriteRule ^([0-9]+).php$ http://pghsource.cagintranet.com/directory/index.php?c=$1 [L]
    
    Code (markup):
    Like i said - everythign worked fine until i put int he top lines about the permanent redirects.

    Now, when ever someone goes to one of the pages listed above, such as /directory/335.php they are redirected to /directory/114.php?c=335

    At first i thoguht - "OK, so that will only happen with 5 pages, thats OK with me." But now in Yahoo - i am getting alot of my pages listed in that syntax... (/directory/xxx.php?c=xxx) - and these pages aren't listed in the 301 section at all. See a screenshot of it here: http://pghsource.cagintranet.com/ERROR.gif

    Can anyone see an error in my htaccess? Ive ran it though validators and nothing is showing up as a problem.
     
    cagintranet, May 12, 2006 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Is

    http://pghsource.cagintranet.com/directory/121.php

    the kind of URL used for the code

    ^([0-9]+).php

    Try puting the Redirect permanent lines last and see if that fixes it. Or try

    RewriteRule ^directory/335.php$ http://pghsource.cagintranet.com/directory/114.php [R=301,L]
    RewriteRule ^directory/317.php$ http://pghsource.cagintranet.com/directory/70.php [R=301,L]
    RewriteRule ^directory/320.php$ http://pghsource.cagintranet.com/directory/310.php [R=301,L]
    RewriteRule ^directory/316.php$ http://pghsource.cagintranet.com/directory/118.php [R=301,L]
    RewriteRule ^directory/339.php$ http://pghsource.cagintranet.com/directory/121.php [R=301,L]
     
    Nintendo, May 12, 2006 IP
  3. cagintranet

    cagintranet Well-Known Member

    Messages:
    328
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #3
    cagintranet, May 12, 2006 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    If you got the .php URLs indexed, it's usually best to just leave it like that. Look at the thread URLs here for example!!!!

    Hopefully it's just Google being on crack that did that.

    It's probably the infinite loop going bonkers that's keeping it from working.
     
    Nintendo, May 12, 2006 IP