1
votes

In Magento, I currently have on the site category urls which have no trailing slash, i.e. www.example.com/gifts

I want to change category urls to have a trailing slash, such as www.example.com/gifts/

To do this I went into the admin section, and edited the SEO section under system -> Configuration -> 'Catalog' -> Search engine optimizations.

There I added a '/' in the Category URL Suffix box.

That is all standard, and after rebuilding the index, the site does indeed display all category urls with a trailing slash, e.g. www.example.com/gifts/

The problem is, when I click on www.example.com/gifts/ (or any category now), I get an infinite redirect loop.

Chrome says "Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.", and doing a CURL -I -0 on the url shows a 301 redirect to Location: /gifts/.

I have checked my htaccess file, and there are definitely no rules related to trailing slash or category redirects.

EDIT: I have logging enabled on htaccess too, and I keep getting lines like:

strip per-dir prefix: /var/www/blah/app-core/index.php -> index.php

Is that normal?

Has anyone seen this issue before, or have any idea at all what might be causing this?

Its a complete blocker for me, so any insight or help would be very appreciated.

Thanks Paul

2

2 Answers

2
votes

Ha ha!!! Sorry, going a bit mad here!

Finally figured it out - I think it might be a bug in Magento 1.4.

In the Mage/Core/Model/Url/Rewrite.php file, request path is given as:

$requestPath = trim($request->getPathInfo(), '/');

So my request of '/gifts/' becomes 'gifts'. Magento then tries to append a slash, and it cycles over ad infinitum.

When you change the trim() to an ltrim(), it works. I.e. $requestPath = ltrim($request->getPathInfo(), '/');

Now '/gifts/' is 'gifts/', and www.example.com/gifts/ is a 200!

Of course its a pain now to have to extend Magento just for such a minor tweak...

0
votes

It sounds like your url rewrite table needs to be rebuilt. Login to your admin area and reindex the url rewrites.