For example I have this url which makes get Request and renders block with specific collection by Id.


Since Magento 2 Url Rewrites only accept /params/paramsvalue how could I rewrite my type of url to make it rewrite friendly like this



1 Answer 1


You can use the following rewrite rules. Either with parameter some_category set with any value:

RewriteCond %{REQUEST_URI} ^/products.*$
RewriteCond %{QUERY_STRING} ^some_category=(.*)$
RewriteRule .* /products/some_category/%1? [R=301,NC,L]

or more general for any parameter and any value:

RewriteCond %{REQUEST_URI} ^/products.*$
RewriteCond %{QUERY_STRING} ^(.*)=(.*)$
RewriteRule .* /products/%1/%2? [R=301,NC,L]

You might want to combine this with the rewrite from your other question regarding the rewrites (Magento 2 query url rewrite), that should be possible but anyway there still may be the issue with the internal rewrite and you need to proxy pass the rewritten request.

The above examples do a 301 redirect, for internal rewrite just remove the R=301 flag, for proxy pass change it to P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.