2016-08-11 133 views
0

我试图递归重定向子目录和驻留在该子目录内的所有子内容。Apache - 递归重定向子目录和所有子内容

假设我有一个子目录/foo/bar,使得它显示为http://www.example.com/foo/bar。我想重定向这个子目录和其中的所有页面和目录到/bar,这样它表现为http://www.example.com/bar。所以当有人访问http://www.example.com/foo/bar时,他们被重定向到http://www.example.com/bar

这需要应用递归一样,所以如下面...

  • http://www.example.com/foo/bar/butterfly.html
  • http://www.example.com/foo/bar/donkey/shrek.html
  • http://www.example.com/foo/bar/elephant/apple/peanut.html

页......所有重定向到以下。

  • http://www.example.com/bar/butterfly.html
  • http://www.example.com/bar/donkey/shrek.html
  • http://www.example.com/bar/elephant/apple/peanut.html

有没有办法做到这一点不单独指定每一页我想重定向?我理解如何做到这一点,至少作为后备方案,但有一条线可以方便得多,而且不用担心需要单独重定向的30多个奇数页。

回答

0

这是一个重定向指令实现

像这样的简单的重定向会做:

Redirect /foo/bar /bar 

哦,这里是官方文档的链接指令文件: Redirect