2
在过去的某个时间,我们的网站的结构类似于www.example.com/departments/it
或www.example.com/departments/asdf
。然后,路径变成www.example.com/it
或www.example.com/asdf
,摆脱'部门'。Apache将文件夹下的所有内容重定向到
有内容,现在生活在/departments/
路径下,因此使用下面的重写规则不起作用
重写规则^ /部门/(.*)$/$ 1 [R = 301,L]
因为虽然它重写部门下的所有内容,但部门本身会重定向回站点根目录。
如何避免这种情况,这样,如果我去www.example.com/it
它的工作原理,www.example.com/departments/it
重定向到www.example.com/it
,如果我去www.example.com/departments/
,我得到了部门信息?