Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.1.1 - URL Rewrite Redirect Loop & 404 Pages (Magento_UrlRewrite Router) #6700

Closed
LoganGS opened this issue Sep 21, 2016 · 3 comments
Closed

Comments

@LoganGS
Copy link
Contributor

LoganGS commented Sep 21, 2016

I am not certain when this began happening, but:

At a certain point after saving a category, the category would go through a redirect loop when I would navigate to it. Products were also having the same issue.

I began looking into it by looking into the Magento\UrlRewrite\Controller\Router::Match() method.

I found that the getRewrite() method was trimming forward slash ("/") characters from the $requestPath variable passed in. This was matching an entity in the "url_rewrite" table with 301 redirect every time.

In the "url_rewrite" table of my database, I had 2 entries that matched the category path. Example:

"some-category-path" (301 - Target Path "some-category-path/")
"some-category-path/" (with a forward slash, Target Path: "catalog/product/view/id/85")

The issue was that the getRewrite() method of the controller was trimming slashes ("/") from $requestPath and always matching the 301 redirect entry.

I did something dirty: I touched core code. All I did was change the trim() function call to ltrim() in the getRewrite() method. Everything seems to be working fine.

Can anybody think of something else that would be causing this? If the trim() method is being called in the getRewrite() method, then any entry in the database ending with a forward slash ("/") should never be matched.

@veloraven
Copy link
Contributor

@LoganGS thank you for your feedback.
Please, format this issue according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result.

@veloraven
Copy link
Contributor

According to contributor guide, tickets without response for two weeks should be closed.
If this issue still reproducible please feel free to create the new one: format new issue according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result and specify Magento version.

@hostep
Copy link
Contributor

hostep commented Jan 20, 2017

Running into a very similar problem here right now, but with custom url rewrites where the request_path is ending with a forward slash.

Changing trim to ltrim fixes our issues, but I'm not sure if this has any negative consequences?

@veloraven: if I provide info to reproduce this according to the guidelines, should I open a new issue, or should we continue in here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants