htaccess 301 重定向文件夹,但不是子文件夹 [英] htaccess 301 redirect folder, but not subfolders

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

问题描述

我需要重定向自:

http://example.com/folder

http://example.com/newfolder

但是离开:

http://example.com/folder/subfolder

它在哪里.这可能吗?我似乎无法在不引起一堆重定向混乱的情况下实现它.

Where it is. Is this possible? I can't seem to make it happen without causing a heap of redirect chaos.

推荐答案

我刚刚遇到了这个问题,这是我想出的解决方案.我更喜欢这种方法,因为它不会重定向任何子目录.

I just ran into this and here's the solution I came up with. I prefer this method because it doesn't redirect any subdirectory.

RewriteCond %{REQUEST_URI} ^/root-directory[/]?
RewriteCond %{REQUEST_URI} !^/root-directory/+[/]?
RewriteRule (.*) http://www.example.com/ [R=301,L]

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

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