【发布时间】:2020-04-27 04:39:09
【问题描述】:
我有一个网站,其中包含一堆旧的域路径。例如。
https://example.com/path1/file.html
https://example.com/path2/file.html
https://example.com/path3/file.html
https://example.com/path4/file.html
我想将所有流量从任何路径重定向到指定路径
https://example.com/my-new-path/file.html
我在我的 htaccess 文件中尝试了以下内容
RedirectMatch 301 ^.*/file.*$ /my-new-path/
但是,这会创建一个重定向循环,我明白为什么。问题是,我不知道如何解决这个问题。
我怎样才能为 .* 任何东西创建一个捕获所有重定向,除了 my-new-path?
【问题讨论】:
标签: regex .htaccess redirect http-status-code-301