为什么 htaccess 重定向被否决?
我有:
重定向 301 /blog/?p=1 http ://www.new-site.com/blog/2000/10/myslug/
工作正常,除非后面跟着:
RedirectMatch 301 ^/blog(/)?(.*)$ http://www.new-site.com/blog/$2
我尝试过各种版本,包括 RewriteRule,但没有任何版本工作了。如何保留第一个特定规则,并编写“其他所有规则都保留其请求 uri 和查询字符串”规则?
谢谢
I've got:
Redirect 301 /blog/?p=1 http://www.new-site.com/blog/2000/10/myslug/
which works fine, unless followed by:
RedirectMatch 301 ^/blog(/)?(.*)$ http://www.new-site.com/blog/$2
I've tried all kinds of versions, including RewriteRule, but nothing has worked. How do I keep the first specific rule, and write an "everything else keeps its request uri and query string" rule?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,假设只有这两行,我看到的是:
Redirect 301 /blog/?p=1 http://www.new-site.com/blog/2000/10/myslug/
RedirectMatch 301 ^/blog(/)?(.*)$ http://www.new-site.com/ blog/$2
这些基本上说的是同一件事,即在一场比赛中,将所有博客查询永久重定向到新站点。
对于第二个,您所说的从头开始匹配字符串
/blog
与可能的斜杠(您将捕获该斜杠),以及可能的更多信息(您还将捕获该信息),然后将所有该信息放入blog/extra-picked-up-info
中。这可能是问题的一部分,或者您可以通过重新排序指令并查看较低的指令是否获得优先权来解决它。否则,您将需要重新检查您的 URI,并找到更具唯一性的标识。
Alright, assuming these are the only two lines, what I see is this:
Redirect 301 /blog/?p=1 http://www.new-site.com/blog/2000/10/myslug/
RedirectMatch 301 ^/blog(/)?(.*)$ http://www.new-site.com/blog/$2
These are basically saying the same thing, that is, on a match, permanently redirect all blog queries to the new site.
With the second one you're saying match from the beginning the string
/blog
with a possible slash, which you'll capture, and possibly more information, which you'll also capture, then just put all that information intoblog/extra-picked-up-info
. This may be part of the problem, or you may be able to get around it by reordering the directives, and seeing if the lower directive receives precedence.Otherwise, you're going to need to reexamine your URIs, and find something more uniquely identifying.