htaccess 301重定向 - 仅限子文件夹选择

时间:2014-08-07 10:05:52

标签: apache .htaccess redirect

我正在尝试重定向/ timetables下的所有子文件夹以及仅子文件夹,因为新网站还有主文件夹/时间表。

我需要的是当用户输入/ timetables / timetable1时,他们被重定向到/ timetables

RedirectMatch 301 ^/timetables /timetables 

< - 当新路径与旧路径不同时,这种重定向对我很有用,但是当它相同时我在页面上得到一个重定向循环。

有没有办法只选择目录的子文件夹并重定向它们?

非常感谢

1 个答案:

答案 0 :(得分:1)

  

我需要的是当用户输入/ timetables / timetable1时,他们被重定向到/ timetables

您可以使用:

RedirectMatch 301 ^/(timetables)/.+ /$1/