Search code examples
apache.htaccesshttp-redirectmod-alias

301 Redirect to single url without autosubstitution


I need to redirect site's visitors from /good/cats to /bad. What i write:

Redirect 301 /good/cats http://somedomain/bad

What i get:

http://somedomain/bad/cats

What should i write to redirect to the http://somedomain/bad?


Solution

  • You need to use RedirectMatch

    RedirectMatch 301 ^/good/cats$  http://somedomain/bad
    

    The reason why your Redirect is not working is because Redirect directive appends additional old path segments to the destination. so the /cats is being appened.