【发布时间】:2019-02-01 18:49:29
【问题描述】:
我一定是第一个对 htaccess 重定向感到沮丧的人,哈哈。
已搜索但找不到解决方案:
我有几个这样的 404:
https://www.example.com/category/uncategorized/page/4/detox
https://www.example.com/category/uncategorized/page/5/detox
https://www.example.com/category/uncategorized/page/6/detox
https://www.example.com/category/uncategorized/page/7/detox
我想这样重定向:
来自
https://www.example.com/category/uncategorized/
以及此下的所有子文件夹或页面
到
https://www.example.com/category/alcohol-drug-rehab/
(只有这个确切的 url,所有子文件夹都应该重定向到这个子文件夹)
我试过了
RedirectMatch 301 ^/category/uncategorized/(.*)$ https://www.example.com/category/alcohol-drug-rehab/
...以及其他几种变体。
但是这会导致如下重定向:
https://www.example.com/category/alcohol-drug-rehab/page/4/detox
https://www.example.com/category/alcohol-drug-rehab/page/5/detox
https://www.example.com/category/alcohol-drug-rehab/page/6/detox
https://www.example.com/category/alcohol-drug-rehab/page/7/detox
如何更改重定向以停止重写后显示子文件夹的 url,而仅重定向到页面 https://www.example.com/category/alcohol-drug-rehab/?
如果可能,我更喜欢直接重写语句而不是 mod 重写,谢谢。
谢谢
【问题讨论】:
-
尝试添加?在规则结束时,空浏览器缓存测试
-
嗨,谢谢,试过了,不高兴,仍然通过在末尾添加子文件夹重定向到错误页面:example.com/category/alcohol-drug-rehab/page/7/detox
-
你清空了浏览器缓存吗?
-
是的,缓存已清除