开发者

Why htaccess redirect being overruled?

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 v开发者_如何学Pythonersions, 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


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 into blog/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.

RedirectMatch 301 /blog(?:/\?)?(.*)?$ http://www.new-site.com/blog/$1
Redirect 301 /blog/?p=1 http://www.new-site.com/blog/2000/10/myslug/

Otherwise, you're going to need to reexamine your URIs, and find something more uniquely identifying.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜