【问题标题】:RewriteRule not working without R flag没有 R 标志,RewriteRule 不起作用
【发布时间】:2017-09-01 12:16:16
【问题描述】:

我需要这个网址:
http://example.net/aroundtheshows/get?id=123

被重写(不重定向)到:
http://example.net/ats/get?id=123

所以我在我的 htaccess 中添加了以下 RewriteRule :

RewriteCond %{REQUEST_URI}  ^\/aroundtheshows
RewriteRule ^aroundtheshows(.*)?$ ats$1 [L]

但它不起作用,我得到一个 404。

但是,如果我有 R=301 标志,重定向工作正常(虽然这不是我想要的,但这意味着匹配是正确的)。

谢谢!

【问题讨论】:

  • 您找到解决方案了吗?面临同样的问题:-\

标签: .htaccess mod-rewrite


【解决方案1】:

如果我理解正确,您希望访问

http://example.net/ats/get?id=123 并在提供来自http://example.net/aroundtheshows/get?id=123 的内容时将其屏蔽为该 URL?

在这种情况下,只需反转您的规则 - 不需要RewriteCond

RewriteRule ^ats(.*) aroundtheshows$1 [L]

在这里演示:http://htaccess.mwl.be?share=1392f5a6-c631-5e90-9ef5-6622644ed517

【讨论】:

猜你喜欢
  • 2011-10-11
  • 2017-11-05
  • 1970-01-01
  • 2015-01-27
  • 1970-01-01
  • 2022-11-26
  • 1970-01-01
  • 1970-01-01
  • 2012-12-10
相关资源
最近更新 更多