【问题标题】:How would I handle this 301 redirect in apache?我将如何在 apache 中处理这个 301 重定向?
【发布时间】:2012-06-13 18:39:16
【问题描述】:

我有很多页面都是从旧网站设置的:

http://www.domain.com/directory/onedirectory/whatever1
http://www.domain.com/directory/onedirectory/whatever2
http://www.domain.com/directory/onedirectory/whatever3

http://www.domain.com/directory/anotherdirectory/whatever1
http://www.domain.com/directory/anotherdirectory/whatever2
http://www.domain.com/directory/anotherdirectory/whatever3

基本上,我已经摆脱了所有“随便”的目录,所以只有一个目录有一个页面(和 index.php),所以现在只有:

http://www.domain.com/directory/onedirectory
http://www.domain.com/directory/anotherdirectory

我将如何使所有“随便”目录重定向回父目录?我不知所措。我尝试了很多方法,但都没有奏效,而且它们通常最终会创建一个无限循环。

提前感谢您的帮助。

-杰里米

【问题讨论】:

    标签: .htaccess mod-rewrite redirect http-status-code-301


    【解决方案1】:

    你想在这里做的最好的事情是使用mod_redirect,例如:-

    ReWriteRule /directory/onedirectory/whatever1 /directory/onedirectory
    

    您甚至可以扩展它并使用正则表达式进行内联替换,请查看this tutorial 以获得一些帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-09
      • 2013-05-26
      • 1970-01-01
      • 2011-02-26
      • 2011-08-02
      • 1970-01-01
      • 2016-02-02
      • 1970-01-01
      相关资源
      最近更新 更多