我的服务器apache中有一个带有重定向的文件.conf,我想使用参数重定向一个url.一个例子是这样的:
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:
example/presente/decoracao/teu-sorriso?PageSpeed=noscript我需要将其重定向到同一页面,如下例所示:
I need to redirect this to the same page, as in the example below:
example/presente/decoracao/teu-sorriso在我的.conf文件中,我尝试以下代码未成功:
In my .conf file, I try the following code without success:
RedirectMatch 301 /presente/decoracao/teu-sorriso$ /presente/decoracao/teu-sorriso?我无法使用.htaccess或Apache RewriteRule方法的重定向.即使进行了研究,研究和尝试,到目前为止,仍未解决任何问题.预先感谢!
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!
推荐答案您不能使用Redirect指令使用query string重定向URL,因为它与?PageSpeed=noscript不匹配.您需要使用Mod-rewrite.
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 .
假设您的服务器上启用了mod-rewrite模块,则可以在Apache配置或htaccess中使用类似以下的内容
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]更多推荐
RedirectMatch 301删除URL参数
发布评论