【问题标题】:.htaccess rewrite get parameter inside the URL.htaccess 重写获取 URL 内的参数
【发布时间】:2015-11-07 11:12:38
【问题描述】:

我在重写 URL 中的 get 参数时遇到了麻烦。

我需要将值替换为 0 或从整个站点的 url 中删除所有下一个请求“filter=all”。

整个请求的示例: mysite.com/?filter=all&search_text=&type=xx&pagination=10&search_page=10&cs_loc_max_input=300&cs_loc_incr_step=1&goe_location_enable=off&submit=

我试过了:

RewriteRule   ^filter=0$   filter=all&%{QUERY_STRING} [L,NC]

RewriteCond %{QUERY_STRING} ^filter=all$
RewriteRule ^filter=0$ ?filter=all&%{QUERY_STRING}[L,NC]

RewriteCond %{QUERY_STRING} ^(.*[&?]|)filter=(all|all2)([&?].*|)$
RewriteRule ^(.*)$ $1?filter=0&%{QUERY_STRING} [R=301,NC,L]

还有更多方法,但没有任何效果...请,需要帮助。 谢谢

【问题讨论】:

  • 您想在浏览器中显示的最终到达网址是什么?

标签: php apache .htaccess mod-rewrite url-rewriting


【解决方案1】:

你可以使用:

RewriteCond %{QUERY_STRING} ^(.*)filter=all(.*)$ [NC]
RewriteRule ^ %{REQUEST_URI}?%1filter=0%2 [R=301,L]

如果您尝试在没有重定向的情况下重写。使用[L] 而不是[R=301,L]

【讨论】:

  • 不客气,很高兴知道它成功了,您可以通过单击我的答案左上角的复选标记将答案标记为已接受。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-04-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-16
相关资源
最近更新 更多