Magento Redirect Loop
-
On my clients site I changed the URL structure for products.
First they had a trailing slash:
I changed it to end in .html
Now rather than redirecting properly, it causes a redirect loop.
Any idea how I can fix this?
-
I would need to look at your code.
but why redirect to .html, it does nothing for you, and does not read as well.
my preferred url is with the slash at the end and no extension, I don't like the slash because people rarely write a slash when manually typing your url, causing a redirect to the slash.
to get rid of slash you need something like
RewriteRule (.)/$ $1 [L,R]
or if you must have .html
RewriteRule (.)/$ $1.html [L,R] -
Hi Ryan,
Have you manually forced a refresh of the catalog url rewrites index and cleared all you caches? Basic I know, but sometimes gets overlooked.
-
Hi. Yes I've done this, on my magento and browser, but had no luck fixing.
-
I thought that the trailing slash for a product page gets seen as a directory. It's not, it's just a page.
What are your throughts on that?
-
It would not mater what it sees it as, its what renders that is important. but web servers can tell what is a directory and what is not, I assume search engines can too.
-
where have you set this redirect, via magneto? or in the .htaccess file?
I would look in my htaccess file and see what redirects are there
-
Alan is right, have a look at your htaccess file in the first instance to see if there are any added redirects that are conflicting with the magento system redirects. If not then I think you have managed to get magento confused switching between the tralling slash and the .html endings.
I agree with Alan that personally I prefer no slash and no .html. It might be worth taking both off and seeing if the system starts redirecting as you expect (on a test server!). If not then you might want to look at emptying your url redirect table in the db and then doing a manual url index update again (again, on a test environment). It seems that the root of your problem is a redirect loop on the trailing slash version of the url (it redirects to itself in other words) and the non trailing slash also redirects to this page. I suspect this is in the magento url db and not through htaccess, but you need to confirm that before messing with the db needlessly.
-
Thanks. I will look into this. great answer.