Reverse a .htaccess redirection rule
Posted
by
Aahan Krish
on Server Fault
See other posts from Server Fault
or by Aahan Krish
Published on 2012-07-04T19:35:19Z
Indexed on
2012/07/04
21:17 UTC
Read the original article
Hit count: 269
Let me explain by example. Say, I have this redirection rule in my .htaccess file:
RedirectMatch 301 ^/([^/]+)/([^/]+)/$ http://www.example.com/$2
What it basically does is, redirect http://www.mysite.com/sports/test-post/
to http://www.mysite.com/test-post/
.
Now, how do I modify the .htaccess rule to do the opposite? (i.e. redirect http://www.mysite.com/test-post/
to http://www.mysite.com/sports/test-post/
)
© Server Fault or respective owner