I have built a custom WordPress theme that displays posts in a modal from the home page.
I need to redirect from
http://example.com/my-post-slug
to
http://example.com/post/my-post-slug
I’ve tried to figure out RedirectMatch but with no luck. So far I tried this but it just causes an infinite loop:
RedirectMatch 301 ^/(.*)$ /post/$1
Any help would be appreciated.
You can use this tweaked regex in the rule:
[^/]+
will not match/post/somepost
hence will not cause any redirect loop. Make sure to clear your browser cache.