RedirectMatch 301删除URL参数

编程入门 行业动态 更新时间:2024-10-24 18:21:56
本文介绍了RedirectMatch 301删除URL参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的服务器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参数

本文发布于:2023-11-01 11:34:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549232.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   RedirectMatch   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!