Htaccess 301重定向子文件夹,但异常 [英] Htaccess 301 Redirect a sub folder with exception

查看:72
本文介绍了Htaccess 301重定向子文件夹,但异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想重定向到除目录以外的子文件夹。

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

我需要的是:

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


推荐答案

您需要使用 RedirectMatch

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

此将会重定向除 blog / wp-admin 以外的所有内容。

This will redirect everything except blog/wp-admin .

如果您使用的是Apache 2.4,也可以使用重定向 if 指令内

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>

这篇关于Htaccess 301重定向子文件夹,但异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆