diwakar khatri
diwakar khatri

Reputation: 23

.htaccess rewrite to redirect a redundant URL to non-redundant URL

I tried to write generic .htaccess commands, so that I could make the below to happen; however not to any success so far.

www.mysite.com/x/x/      Redirects to   www.mysite.com/x/
www.mysite.com/x/y/y/    Redirects to   www.mysite.com/x/y/
www.mysite.com/x/y/y/x/  Redirects to   www.mysite.com/x/

Please note that I'm trying to make this very generic, i.e. x and y can be any directory names. Any help will be much appreciated.

Thanks, Diwakar

Upvotes: 0

Views: 83

Answers (1)

Mayank Kapahi
Mayank Kapahi

Reputation: 326

Apply following redirects in your htaccess

  Redirect 301 /x/x/ /x/
  Redirect 301 /x/y/y/ /x/y/
  Redirect 301 /x/y/y/x/ /x/

Upvotes: 1

Related Questions