重定向301中的重定向过多 [英] Too many redirects in redirect 301

查看:98
本文介绍了重定向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

  1. URI为/php/zend-framework/captcha-codigo-anti-spam-zend-framework
  2. RedirectMatch指令与URI匹配,重定向到:

  1. The URI is /php/zend-framework/captcha-codigo-anti-spam-zend-framework
  2. The RedirectMatch directive matches the URI, redirects to:

http://www.demo31.com/blog/php/zend-framework/captcha-codigo-anti-spam-zend-framework

  • 新URI是/blog/php/zend-framework/captcha-codigo-anti-spam-zend-framework
  • 但是,RedirectMatch指令再次匹配URI ,因为它包含/php/zend-framework/captcha-codigo-anti-spam-zend-framework
  • new URI is /blog/php/zend-framework/captcha-codigo-anti-spam-zend-framework
  • however, the 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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆