问题
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