mod_rewrite 附加字符串到查询
我正在尝试转换此 URL:
http://localhost/?q=foo&s=search
对此:
http://localhost/?q=+foo&s=search (i add a plus sign before the user query)
我尝试过:
RewriteCond %{QUERY_STRING} ^q=(.*)$ [NC]
RewriteRule ^(.*)$ /?q=\+%1 [R=301,L,NE]
但这会生成:
http://localhost/?q=+++++++++++++++++++++foo
关于如何在查询之前添加加号的任何建议?
I'm trying to transform this URL:
http://localhost/?q=foo&s=search
on this:
http://localhost/?q=+foo&s=search (i add a plus sign before the user query)
I tried with:
RewriteCond %{QUERY_STRING} ^q=(.*)$ [NC]
RewriteRule ^(.*)$ /?q=\+%1 [R=301,L,NE]
But this generates:
http://localhost/?q=+++++++++++++++++++++foo
Any advice on how to add the plus sign before the query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两个快速/简单的选项:
+
(PHP:$query = '+' . $_GET['q'];
)添加参数指示重定向和避免重定向。
Two quick/easy options:
+
in the backend (PHP:$query = '+' . $_GET['q'];
)Add a param indicating the redirect and avoiding the redirect.