重定向301中的重定向过多 [英] Too many redirects in redirect 301
问题描述
我想将301从旧的ulr重定向到新的网址.
I want to make a redirect 301 from an old ulr to a new url.
旧网址:/php/zend-framework/captcha-codigo-anti-spam-zend-framework
新网址:http://www.demo31.com/blog/php/zend-framework/captcha-codigo-anti-spam-zend-framework
在.htaccess中,我像这样进行重定向...
In .htaccess I make this redirect like this ...
RedirectMatch 301 /php/zend-framework/captcha-codigo-anti-spam-zend-framework http://www.demo31.com/blog/php/zend-framework/captcha-codigo-anti-spam-zend-framework
但是我遇到了错误"ERR_TOO_MANY_REDIRECTS".
But I've got the error "ERR_TOO_MANY_REDIRECTS".
我做错了什么?
推荐答案
看起来两个URI都在同一主机上(www.demo31.com
),因此当您使用RedirectMatch
时,匹配的URI部分就是一部分重定向.例子
It looks like both URI's are on the same host (www.demo31.com
), so when you use RedirectMatch
, the part of the URI that matches is part of the redirect. Example
如果我去
http://www.demo31.com/php/zend-framework/captcha-codigo-anti-spam-zend-framework
- URI为
/php/zend-framework/captcha-codigo-anti-spam-zend-framework
-
RedirectMatch
指令与URI匹配,重定向到:
- The URI is
/php/zend-framework/captcha-codigo-anti-spam-zend-framework
The
RedirectMatch
directive matches the URI, redirects to:
http://www.demo31.com/blog/php/zend-framework/captcha-codigo-anti-spam-zend-framework
/blog/php/zend-framework/captcha-codigo-anti-spam-zend-framework
RedirectMatch
指令再次匹配URI ,因为它包含/php/zend-framework/captcha-codigo-anti-spam-zend-framework
/blog/php/zend-framework/captcha-codigo-anti-spam-zend-framework
RedirectMatch
directive matches the URI again since it contaings /php/zend-framework/captcha-codigo-anti-spam-zend-framework
尝试将RedirectMatch
更改为仅Redirect
.或者,如果您只希望重定向特定的URI(而不是像/php/zend-framework/captcha-codigo-anti-spam-zend-framework/some/other/stuff
这样的重定向,也可以添加一些定界符:
Try changing RedirectMatch
to just Redirect
. Or if you only want that specific URI to redirect (as opposed to something like /php/zend-framework/captcha-codigo-anti-spam-zend-framework/some/other/stuff
also getting redirected, add a few delimiters:
RedirectMatch 301 ^/php/zend-framework/captcha-codigo-anti-spam-zend-framework$ http://www.demo31.com/blog/php/zend-framework/captcha-codigo-anti-spam-zend-framework
(^
和$
这篇关于重定向301中的重定向过多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!