José Carlos
José Carlos

Reputation: 2922

Too many redirects in redirect 301

I want to make a redirect 301 from an old ulr to a new url.

old url: /php/zend-framework/captcha-codigo-anti-spam-zend-framework

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

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

But I've got the error "ERR_TOO_MANY_REDIRECTS".

What am I doing wrong?

Upvotes: 0

Views: 3796

Answers (2)

pierre delaunay
pierre delaunay

Reputation: 21

RewriteRule ^bad_url$ good_url [R=301,L] 

Thx ! works for me

Upvotes: 0

Jon Lin
Jon Lin

Reputation: 143906

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

If I go to:

http://www.demo31.com/php/zend-framework/captcha-codigo-anti-spam-zend-framework
  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
    
  3. new URI is /blog/php/zend-framework/captcha-codigo-anti-spam-zend-framework
  4. however, the RedirectMatch directive matches the URI again since it contaings /php/zend-framework/captcha-codigo-anti-spam-zend-framework

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

(the ^ and $

Upvotes: 2

Related Questions