I have a file .conf
in my server apache with the redirects and 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 .conf
file, I try the following code without success:
RedirectMatch 301 /presente/decoracao/teu-sorriso$ /presente/decoracao/teu-sorriso?
I can not use redirects from .htaccess
nor the Apache RewriteRule
method.Even researching, researching and trying, so far nothing has worked out. Thanks in advance!
You can not redirect a URL with query string
using Redirect
directive as it doesn't match against ?PageSpeed=noscript
. You need to use Mod-rewrite
.
Assuming mod-rewrite
module is enabled on your server , you can use something like the following in your Apache config or htaccess
RewriteEngine on
RewriteCond %{QUERY_STRING} ^PageSpeed=noscript$ [NC]
RewriteRule ^/?presente/decoracao/teu-sorriso/?$ /presente/decoracao/teu-sorriso? [L,R=301]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.