StackOverflower
StackOverflower

Reputation: 1097

.htaccess Redirect Directory To Subdirectory

I am attempting to redirect my page

http://example.com/category/general/

to

http://example.com/blog/category/general/

I thought that this would work but it ends up endlessly looping

RedirectMatch 301 /category/general/ /blog/category/general/

Upvotes: 2

Views: 979

Answers (1)

anubhava
anubhava

Reputation: 784918

You must use regex anchors as well:

RedirectMatch 301 ^/category/general/?$ /blog/category/general/

And with capturing groups:

RedirectMatch 301 ^/(category/general/?)$ /blog/$1

Test this after clearing your browser cache.

Upvotes: 3

Related Questions