Mod_rewrite 条件不起作用

发布于 2024-09-04 06:14:21 字数 508 浏览 1 评论 0原文

我检查了正则表达式,它们都匹配,但由于某种原因它在 mod_rewrite 中不起作用?

我想要

http://www.system.com/chips/intel?c=xxx

阅读:

http://www.system.com/chips/intel/xxx

我有:

RewriteCond %{REQUEST_URI} (c=.*)$
RewriteRule (/([^/]+)/?).*?c=(.*) http://%{SERVER_NAME}/$1/$2/ [L]

我得到了一个错误。这是怎么回事?

I've checked the regexs and they all match but for some reason its not working in mod_rewrite?

I would like

http://www.system.com/chips/intel?c=xxx

to read:

http://www.system.com/chips/intel/xxx

I have:

RewriteCond %{REQUEST_URI} (c=.*)$
RewriteRule (/([^/]+)/?).*?c=(.*) http://%{SERVER_NAME}/$1/$2/ [L]

And I'm getting an error. What's going on here?

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

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

发布评论

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

评论(2

清醇 2024-09-11 06:14:21

您的正则表达式与该 URL 不匹配。如您所见:

  • 组 1 匹配 /chips/
  • 组 2 匹配 chips
  • 组 3 匹配 xxx

您可能想要类似的东西:

RewriteRule ^/([^/]+)/([^/]+)\?c=([^&]*)  http://%{SERVER_NAME}/$1/$2/$3 [R=301]

Your regular expression doesn't match that URL. As you have it:

  • group 1 matches /chips/
  • group 2 matches chips
  • group 3 matches xxx

You probably want something like:

RewriteRule ^/([^/]+)/([^/]+)\?c=([^&]*)  http://%{SERVER_NAME}/$1/$2/$3 [R=301]
淡淡の花香 2024-09-11 06:14:21

不要认为 rewritecond get 是 uri 参数,除非你有“QSA”

http:// /httpd.apache.org/docs/2.0/mod/mod_rewrite.html

Don't think rewritecond get's the uri params unless you have "QSA"

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

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