In the file .htaccess in magento, I want to redirect a url with parameters. An example is this:


I need to redirect this to the same page, as in the example below:


In my .htaccess file, I try the following code without success:

RewriteRule ^presente/decoracao/teu-sorriso(.*)$    /presente/decoracao/teu-sorriso? [L,R=301]

When I use the %{REQUEST_URI} syntax it always redirects me to /index.php because of the particularities of Magento. Another way I tried was the following, but without success too:

RewriteCond %{QUERY_STRING} ^PageSpeed=noscript$ [NC]
RewriteRule ^/?presente/decoracao/teu-sorriso/?$ /presente/decoracao/teu-sorriso? [L,R=301]

I've been trying to do this in several ways, but all of them to no avail. Thanks in advance!

1 Answer 1


You can try to use two rewrite conditions - one for the QUERY_STRING and one for the REQUEST_URI and let the matching pattern be .* in the rewrite rule.

RewriteCond %{QUERY_STRING} ^PageSpeed=noscript$ [NC]
RewriteCond %{REQUEST_URI} ^/presente/decoracao/teu-sorriso/?$
RewriteRule .* /presente/decoracao/teu-sorriso? [L,R=301]
  • I put this code before the last rewrite of the standard Magento, in this case RewriteRule .* index.php [L], right? Apr 18, 2019 at 15:04
  • Better as the first rule, right after RewriteEngine on then you have no interference with other rules
    – HelgeB
    Apr 18, 2019 at 15:05

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.