【问题标题】:Apache redirect everything under a folder except the folder itselfApache重定向文件夹下的所有内容,但文件夹本身除外
【发布时间】:2013-05-20 18:45:47
【问题描述】:

在过去的某个时候,我们的网站具有类似www.example.com/departments/itwww.example.com/departments/asdf 的结构。然后,路径更改为www.example.com/itwww.example.com/asdf 之类的东西,摆脱了“部门”。

现在/departments/ 路径下存在内容,因此使用以下重写规则不起作用

重写规则 ^/departments/(.*)$ /$1 [R=301,L]

因为当它重写部门下的所有内容时,部门本身会被重定向回站点根目录。

如何防止这种情况发生,如果我转到 www.example.com/it 它可以工作,www.example.com/departments/it 会重定向到 www.example.com/it,如果我转到 www.example.com/departments/,我会得到部门信息?

【问题讨论】:

    标签: apache redirect rewrite


    【解决方案1】:

    粘贴进去试试看

    重写规则 ^/departments/it$ /it/$1 [R=301,R,L]

    【讨论】:

      猜你喜欢
      • 2017-05-26
      • 2016-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      相关资源
      最近更新 更多