如何在lighttpd中重写特定的URL

问题描述 投票:0回答:1

我将lighttpd上的wiki安装从https://www.example.com/wiki移动到https://wiki.example.com的子域,因此我需要重定向与新子域相关的任何wiki。

url.rewrite-once =(“^ / wiki”=>“https://wiki.example.com”,

)

这给了我一个错误404找不到,因为浏览器仍然指向旧页面。

另外我想添加一个规则来处理已经有书签的页面,例如发送

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-rewriting lighttpd
1个回答
0
投票

虽然Stackoverflow是一个很好的资源,但请尝试阅读您询问的工具的主要源文档。在这种情况下,这是lighttpd文档。

您可以考虑使用mod_redirect重定向客户端。请参阅https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModRedirect上的文档和示例

© www.soinside.com 2019 - 2024. All rights reserved.