Reverse a .htaccess redirection rule
- by Aahan Krish
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/)