Koozali.org: home of the SME Server

Contribs.org Forums => General Discussion => Topic started by: jameswilson on July 03, 2025, 06:25:03 PM

Title: rewrite issue
Post by: jameswilson on July 03, 2025, 06:25:03 PM
Not a SME Issue but ive noticed a significat drop in traffic
Anyhow ive found out some pages are causing errors this is one of them
https://www.securitywarehouse.co.uk/catalog/intruder-alarm-equipment-c-36/movement-detectors-c-36_116/all-c-36_116_37/bosch-blue-line-gen2-pet-friendly-passiveinfrared-detector-p-2292.html

and the error shown is www.securitywarehouse.co.uk redirected you too many times.

im assuming i have a setting error in htaccess but i have no clue where to start
Any pointers please

Ta
James
Title: Re: rewrite issue
Post by: Jean-Philippe Pialasse on July 04, 2025, 10:47:09 PM
looking at your htaccess ?
Title: Re: rewrite issue
Post by: mmccarn on July 05, 2025, 01:05:24 PM
If you suspect your htaccess file you could try this online htaccess tester: https://htaccess.madewithlove.com/

I found the tester above in this stackoverflow question:

Tips for debugging .htaccess rewrite rules
Asked 13 years, 5 months ago
Modified 6 months ago
Viewed 147k times (https://stackoverflow.com/questions/9153262/tips-for-debugging-htaccess-rewrite-rules)
Title: Re: rewrite issue
Post by: jameswilson on July 08, 2025, 04:20:03 PM
mmccarn
Thanks for the link to htaccess tester but i dont understand the output but it doesnt look good

https://htaccess.madewithlove.com?share=d19e705a-d8de-4709-b6f9-ad0cd120c8d3
Title: Re: rewrite issue
Post by: jameswilson on July 15, 2025, 06:00:37 PM
is it safe to post the htaccess file?
Title: Re: rewrite issue
Post by: ReetP on July 16, 2025, 11:41:13 AM
is it safe to post the htaccess file?

As long as it doesn't include any personal information or obvious security issues :-)
Title: Re: rewrite issue
Post by: mmccarn on July 16, 2025, 01:09:29 PM
Your htaccess file is already available in the link you sent to the htaccess tester.

Note that in that site, it appears that only one product ID produces the infinite redirect issue. 

If I change the product ID I get a real product page...

On the htaccess tester site:

Input URL:
https://www.securitywarehouse.co.uk/catalog/intruder-alarm-equipment-c-36/movement-detectors-c-36_116/all-c-36_116_37/bosch-blue-line-gen2-pet-friendly-passiveinfrared-detector-p-2292.html

Output URL:
https://www.securitywarehouse.co.uk/index.php?main_page=product_info&products_id=2292&cPath=36_116_37&

...then put the output URL into the Input URL field:

Input URL:
https://www.securitywarehouse.co.uk/index.php?main_page=product_info&products_id=2292&cPath=36_116_37&

Output URL (identical):
https://www.securitywarehouse.co.uk/index.php?main_page=product_info&products_id=2292&cPath=36_116_37&

Result:
"The page isn’t redirecting properly"

If you change products_id to 2291 and repeat:

Input URL:
https://www.securitywarehouse.co.uk/index.php?main_page=product_info&products_id=2291&cPath=36_116_37&

Output URL:
https://www.securitywarehouse.co.uk/index.php?main_page=product_info&products_id=2291&cPath=36_116_37&

Result: Model: ISC-BPR2-W12

...so there there seems to be something unique about products_id 2292
Title: Re: rewrite issue
Post by: mmccarn on July 16, 2025, 01:48:23 PM
Note that if you don't find an actual problem with "-p-2292", you could update your htaccess to rewrite only that id to something else:

Code: [Select]
. # Handles the new URL formats
+ RewriteRule ^(.*)-c-([0-9_]+)/(.*)-p-2292(.*)$ index.php?main_page=product_info&products_id=2291&cPath=$2&%{QUERY_STRING} [L]
  RewriteRule ^(.*)-c-([0-9_]+)/(.*)-p-([0-9]+)(.*)$ index.php?main_page=product_info&products_id=$4&cPath=$2&%{QUERY_STRING} [L]
  RewriteRule ^(.*)-c-([0-9_]+)/(.*)-pi-([0-9]+)(.*)$ index.php?main_page=popup_image&pID=$4&cPath=$2&%{QUERY_STRING} [L]
...
Title: Re: rewrite issue
Post by: mmccarn on July 16, 2025, 02:26:13 PM
There is a rule near the top of your htaccess that matches any URL containing "index.php".

I found this note on stackoverflow (https://stackoverflow.com/questions/13832468/how-to-stop-htaccess-loop) indicating you might get what you want by change the action on that rule from [L] to [END]

Code: [Select]
- RewriteRule ^index\.php$ - [L]
+ RewriteRule ^index\.php$ - [END]