1

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

https://example.com/presente/decoracao/teu-sorriso?PageSpeed=noscript

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

https://example.com/presente/decoracao/teu-sorriso

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!

asked Apr 18, 2019 at 13:59

1 Answer 1

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]
answered Apr 18, 2019 at 14:57
2
  • I put this code before the last rewrite of the standard Magento, in this case RewriteRule .* index.php [L], right? Commented Apr 18, 2019 at 15:04
  • Better as the first rule, right after RewriteEngine on then you have no interference with other rules Commented Apr 18, 2019 at 15:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.