Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

301 Loop (htaccess)


BanjoMan73

Recommended Posts

Looking to create a 301 redirect for certain urls on my website, but I end up getting a Redirect Loop.

 

These are the current rewrites within the htaccess. The cPath is the one that is causing the loop and adding on the additional string info at the end, and from what I can see this isn't used within the website.

 

Any tips/advice on how to advoid the 301 redirect loop would be great.

 

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^RrtM(.*)$ /pages.php?%{QUERY_STRING} [L]

 

RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}

RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}

RewriteRule ^(.*)-m-(.*).html$ index.php?manufacturers_id=$2&%{QUERY_STRING}

RewriteRule ^(.*)-pi-(.*).html$ popup_image.php?pID=$2&%{QUERY_STRING}

Link to comment
Share on other sites

What happens if you leave &%{QUERY_STRING} off, and use [QSA] instead? If you provide a query string in the rewrite, you use the QSA flag to append any existing query string. If you do not provide any query string in the rewrite, it should append the existing query string to the output. If you want to suppress any existing query string, just end the output with ?. (This is from memory, which isn't what it used to be!)

 

What happens if the request is not a file or directory, but doesn't start with RrtM? How do you want it handled?

 

You might try commenting out the pages.php rule lines first, to make sure the other 4 RewriteRules are OK, and then reverse it to check the first 3 lines. Try the following:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^RrtM(.*)$ /pages.php [L]

RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2 [QSA]
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2 [QSA]
RewriteRule ^(.*)-m-(.*).html$ index.php?manufacturers_id=$2 [QSA]
RewriteRule ^(.*)-pi-(.*).html$ popup_image.php?pID=$2 [QSA]

 

Hopefully that will get you closer to your goal. By the way, where are you doing a 301 redirect? I see only 200 redirects here.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...