重定向查询字符串

发布于 2024-09-11 09:39:14 字数 300 浏览 1 评论 0原文

我正在尝试进行重定向,但它不起作用。

我想重定向:

http://www.example.com/page/168?s  

至:

http://www.example.com/page/168

使用

RewriteCond %{QUERY_STRING} ^q=s$  
RewriteRule ^(.*)$ http://www.example.com/$1? [R=301,L]

I am trying to do the redirect, but it is not working.

I want to redirect:

http://www.example.com/page/168?s  

To:

http://www.example.com/page/168

Using

RewriteCond %{QUERY_STRING} ^q=s$  
RewriteRule ^(.*)$ http://www.example.com/$1? [R=301,L]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青丝拂面 2024-09-18 09:39:14

我找到了解决方案:

RewriteCond %{QUERY_STRING} ^s$  
RewriteRule ^(.*)$ http://www.example.com/$1? [R=301,L]    

如果有人需要的话

谢谢

I found the solution:

RewriteCond %{QUERY_STRING} ^s$  
RewriteRule ^(.*)$ http://www.example.com/$1? [R=301,L]    

In case of somebody to need

Thank you

流心雨 2024-09-18 09:39:14

您需要QSA(查询字符串附加):

Using RewriteCond %{QUERY_STRING} ^q=s$
RewriteRule ^(.*)$ http://www.example.com/$1? [R=301,L,QSA]

否则重写不包括问号后面的部分。

You need QSA (Query string append):

Using RewriteCond %{QUERY_STRING} ^q=s$
RewriteRule ^(.*)$ http://www.example.com/$1? [R=301,L,QSA]

Otherwise the the rewrite does not include the part after the questionmark.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文