【发布时间】:2016-12-18 12:58:18
【问题描述】:
我正在尝试递归重定向子目录以及该子目录中的所有子内容。
假设我有一个子目录/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.htmlhttp://www.example.com/foo/bar/donkey/shrek.htmlhttp://www.example.com/foo/bar/elephant/apple/peanut.html
...全部重定向到以下内容。
http://www.example.com/bar/butterfly.htmlhttp://www.example.com/bar/donkey/shrek.htmlhttp://www.example.com/bar/elephant/apple/peanut.html
有没有办法在不单独指定我要重定向的每个页面的情况下做到这一点?我知道如何做到这一点,至少作为一种后备,但如果有一行而不用担心我需要单独重定向 30 多个奇怪的页面会更方便。
【问题讨论】:
标签: apache redirect httpd.conf