Redirect Loop - Please Help!

Discussion in 'Apache' started by web_junkie, May 29, 2009.

  1. #1
    Hi, I am kind of new at this. I want to rewrite one my URls to a more search engine friendly name, but also want to redirect traffic and page rank from the old url to the new one.
    After doing some reading, this is the best I came up with, for my . htaccess file :

    RewriteRule ^fireplace-rugs$ results.php?category=5 [L]
    RewriteCond %{QUERY_STRING} ^category=5$
    RewriteRule ^results\.php$ http://www.mysite.com/fireplace-rugs? [R=301,L]


    I guess something is very wrong with this script because I keep getting a redirect loop on Firefox when I request the page.

    I was wondering if someone can give a hand to make this code work. I will really appreciated


    Thanks
     
    web_junkie, May 29, 2009 IP
  2. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #2
    Try to copy/rename that results.php to something else.. like resultsNEW.php or something like that... and then add this:

    
    RewriteRule ^fireplace-rugs$ resultsNEW.php?category=5 [L]
    RewriteCond %{QUERY_STRING} ^category=5$ 
    RewriteRule ^results\.php$ http://www.mysite.com/fireplace-rugs? [R=301,L]
    
    Code (markup):

    If this is the only work of your results.php then you can just rename it. If your script is doing other work as well, besides hitting this page, then just copy results.php to resultsNEW.php and change those lines above in your .htaccess
    Note: Do not change results.php to resultsNEW.php in both lines above, just change it in the first one, and leave results.php in that third line as it is. That should work fine, and you'll avoid loop bug.
     
    pr0t0n, Jun 5, 2009 IP
  3. web_junkie

    web_junkie Active Member

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #3
    web_junkie, Jun 6, 2009 IP