Htaccess 301 Redirect a sub folder with exception

心已入冬 提交于 2019-12-11 04:38:32

问题


I would like to redirect to a sub-folder except a dir.

What I need is:

Redirect 301 /blog/ /blog-post/
#Exclude /blog/wp-admin/

回答1:


You need to use RedirectMatch :

RedirectMatch 301 ^/blog/((?!wp-admin).+) /blog-post

This will redirect everything except blog/wp-admin .

If you are on apache 2.4 you can also use Redirect inside if directive

<if "%{REQUEST_URI} !~ m#/blog/wp-admin/#">
Redirect 301 /blog/ /blog-post/
</if>


来源:https://stackoverflow.com/questions/38157262/htaccess-301-redirect-a-sub-folder-with-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!