【发布时间】:2019-04-30 10:05:55
【问题描述】:
我将 lighttpd 上的 wiki 安装从 https://www.example.com/wiki 移动到 https://wiki.example.com 的子域,因此我需要重定向与新子域相关的任何 wiki。
url.rewrite-once = ( "^/wiki" => "https://wiki.example.com",
)
这给了我一个错误 404 not found 因为浏览器仍然指向旧页面。
此外,我想添加一个规则来处理人们已经收藏的页面,例如发送
https://www.example.com/wiki/index.php?title=Main_Page
到 https://wiki.example.com/index.php?title=Main_Page
我最终这样做了:
url.redirect = ( "^/wiki/(.*)$ => https://wiki.example.net/$1",
"^/wiki/([^?]*)(?:\?(.*))?" => "https://wiki.example.net/index.php?title=$1&$2",
)
这适用于 99% 的网站。但是,有一些论坛主题现在无法正确显示,因为它们正在尝试重定向。
这个可以正常查看论坛
https://www.example.net/forums/showthread.php?796166-Wiki-Skins
这个中断并尝试重定向
https://www.twcenter.net/forums/showthread.php?796105-Wiki-Extensions-amp-Gadgets
【问题讨论】:
-
第一个 url.redirect 匹配获胜,因此第二个规则(在您的编辑中)将永远不会执行。颠倒这些规则的顺序,将更专业的匹配放在第一位,将更通用的匹配放在第二位。