简体   繁体   中英

.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/

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM