I am migrating a store from an old custom commerce system to Magento 2. I am trying to add URL rewrites into Magento 2 using the Marketing -> Url Rewrite tool.
The old URLs for the store look like this:
store/detail/x.php?id=123
I can enter that into the Request Path just fine, but anything with a ? in it never actually forwards to the Target Path. If I remove the ?, it redirects fine.. but obviously that is not a valid URL.
Any ideas or suggestions?
2 Answers 2
Magento 2 reads parameters in the following format:
somepage/param/param_value/
It ignores the question mark. In your situation you have 2 options to go:
1) Manage this by using the rewrite rules of the webserver.
For more information on this, please check:
- Nginx - https://www.nginx.com/blog/creating-nginx-rewrite-rules/
- Apache - https://httpd.apache.org/docs/2.4/rewrite/remapping.html
2) Write your custom router for processing URLs
Please see my example on how to do this there: Configure front name in admin panel
-
I was trying to avoid this route, but it looks easier to put them in nginx than it does to create a new url processor.Adam R.– Adam R.2018年10月16日 16:48:06 +00:00Commented Oct 16, 2018 at 16:48
You can create a module which works the same as a htaccess rewrite rule. After two days trying to get htaccess rewrite to work I found this works perfectly for Magento 2.4: https://magento.stackexchange.com/a/158811/109113