【问题标题】:Apache - Recursively redirect sub directory and all child contentApache - 递归重定向子目录和所有子内容
【发布时间】: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.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 多个奇怪的页面会更方便。

【问题讨论】:

    标签: apache redirect httpd.conf


    【解决方案1】:

    这是通过重定向指令实现的

    这样一个简单的重定向就可以了:

    Redirect /foo/bar /bar
    

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

    【讨论】:

      猜你喜欢
      • 2022-01-22
      • 2013-09-23
      • 1970-01-01
      • 2010-12-31
      • 2014-10-16
      • 1970-01-01
      • 2020-08-19
      • 1970-01-01
      • 2015-10-23
      相关资源
      最近更新 更多