-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
UrlRewrite removes query string from url, if url has trailing slash #18717
Comments
Hi @sergeynezbritskiy. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
where @sergeynezbritskiy do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
https://github.com/sergeynezbritskiy/magento2/commit/7e26ec6a7cf1de8343ab05555de5a687da1518b8 |
@sergeynezbritskiy, URLs like http://magento-host.com/catalog/product/view/id/{product-id}/?foo=bar&bar=baz is not the right way to go. It should look like http://magento-host.com/catalog/product/view/id/{product-id}/foo/bar/bar/baz/ instead. |
@orlangur actually we can't change url format due to our SEO team restrictions. Moreover default magento layered navigation uses urls with query string, e.g. here is url from my local demo installation with sample data: http://demo.magento2.local/women/tops-women/jackets-women?climate=202; When I add trailing slash (http://demo.magento2.local/women/tops-women/jackets-women/?climate=202, which is actually a valid url in terms of http protocol),Magento redirects me to http://demo.magento2.local/women/tops-women/jackets-women. |
@orlangur due to my investigation, the issue probably comes from \Magento\UrlRewrite\Model\Storage\DbStorage:doFindOneByData, which returns 301 redirect for request_path with trailing slash, when it founds url rewrite with exactly the same request_path but without trailing slash, but not clear why the should be any redirect. |
Hi @engcom-backlog-andrii. Thank you for working on this issue.
|
@engcom-backlog-andrii Thank you for verifying the issue. Based on the provided information internal tickets |
Hi @shikhamis11. Thank you for working on this issue.
|
#MM19IN |
I am also able to reproduce this issue at magento 2.2-develop and 2.3-develop instance |
@sergeynezbritskiy your solution is seems fine I am creating Pull request with this |
Thank you for your report and collaboration! The issue was fixed by Magento team. The fix was delivered into
The fix will be available with the upcoming |
@magento-engcom-team give me 2.3.3 instance |
Hi @arendarenko. Thank you for your request. I'm working on Magento 2.3.3 instance for you |
Hi @arendarenko, here is your Magento instance. |
@magento-engcom-team give me 2.3-develop instance |
Hi @arendarenko. Thank you for your request. I'm working on Magento 2.3-develop instance for you |
Hi @arendarenko, here is your Magento instance. |
Hi @magento-engcom-team It may cause SEO-indexation issues. I think that proper way is redirect to url without trailling slash AND keep query params in it, e.g /some-url/?a=b => /some-url?a=b |
Hi @sdzhepa. Thank you for working on this issue.
|
Hello @sergeynezbritskiy I just received an update about this issue from the internal Jira ticket. Previously it was fixed by internal Magento team and delivered with internal Pull Request in the scope of Sometime later were found additional bugs after this fix and it was a reason for several internal discussions and investigation. Finally, after architect approval, it was decided to revert these changes. Here is a quote with an explanation :
Also, additional information about "how existing GET parameters being treated during redirection" was added/updated to the DevDocs (magento/merchdocs#128)
|
I have this exact issue on Magento 2.2.10. Steps to reproduce Expected result Actual result Additional information Can anyone advise on the best code fix? |
Hi, We discussed this issue with @akaplya and did following decision: Adding support for getting GET params to the redirect might cause security issue. Potential security issuesExample 1: In case if targetPath will be set to external URL - this session ID will be sent to external website and could be used by potential hackers. Example 2 Here is options that we found that could be secure Potential secure options
We could detect if target URL is external in following ways: How to detect if target URL is externala. During saving URL rewrite - add validation if target URL is external - add to extra params some flag that shows that it's internal/external URL, and if it's internal URL - we could add GET params, otherwise - do not add them. We could start there from auto-generated URL rewrites, looks like it will be enough. b. In case if target path NOT contains http:// or https:// - treat such URL as internal and add GET parameters, otherwise treat such URL as external and don't add GET parameters. I believe implementing option 2b is the easiest way. |
This is a major issue. Our pagination stopped working. Applying |
Very strange as we're having slash as url suffix for categories and we don’t have this issue on Magento 2.3.2-p2. Could you add steps to reproduce on clear magento installation? |
@ihor-sviziev obviously not since the "fix" referred to here was introduced in 2.3.3 for anyone else fucked over by this, here's a module that applies the fix from #25603 on top of the revert fa468e7 - or if your client has a stick up their arse maybe you can just put this code in app/code/FTS/FixTrailingSlash xoxo |
Thank you @maaarghk for providing the link to the code which helped me solve this issue. The Magento 2.3.3 release note under URL Rewrites states:
But from what I have seen in 2.3.3 it looks like it now strips out the all query string parameters regardless of whether there is a trailing slash or not in the url. This has now broken pagination and # items per page functionality on category page urls such as /square-gutter-brown-c-774/?product_list_limit=all As you pointed out, the culprit here are the changes in Magento\UrlRewrite\Controller\Router which finds a match for the category in the "url_rewrite table" (because it is a category and under the covers it is redirecting to: /catalog/category/view/id/774) once it actions the redirect it looses all the query string parameters. Feels like a slightly different issue to the one raised here and I am tempted to raise a new ticket but as the last 2 have been closed without even basic checking I'm not going to bother, seems like it is every man for themselves with Magento support at the moment. |
Hi @sergeynezbritskiy. Thank you for your report.
The fix will be available with the upcoming 2.4.0 release. |
Thanks @maaarghk confirms that your note helps me resolve the issue in 2.3.3. Magento 2.3.3 stops working on infinity loading cause by param issue. Added your extension fixed the issue. |
Preconditions (*)
When customer opens url with trailing slash and query string like http://magento-host.com/some-url-key/?foo=bar, Magento redirects to url without trailing slash and truncates query string, so customer is redirected to http://magento-host.com/some-url-key.
Steps to reproduce (*)
/?foo=bar&bar=baz
to the url and open this linkExpected result (*)
Actual result (*)
Additional information
We are looking for both urls (with trailing slash and without it), but when verifying the result from database we do not check it.
The text was updated successfully, but these errors were encountered: