我的应用有两个重定向,
$HTTP["host"] =~ "^(.*)$" {
url.redirect = ( "^/(.*)\.(markdown|md)$" => "http://%1/$1.html")
}
$HTTP["host"] =~ "^www\.(.*)$" {
url.redirect = ( "^/(.*)" => "http://%1/$1" )
}
一个将markdown或md扩展名重定向到html版本,其他将www重定向到非www。但是一个取代另一个取决于后者。
答案 0 :(得分:0)
如果翻转重定向的顺序,则应达到所需的结果。
$HTTP["host"] =~ "^www\.(.*)$" {
url.redirect = ( "^/(.*)" => "http://%1/$1" )
}
else $HTTP["host"] =~ "^(.*)$" {
url.redirect = ( "^/(.*)\.(markdown|md)$" => "http://%1/$1.html")
}
案例1
1. http://www.agilityspeaks.com/test.md redirects to http://agilityspeaks.com/test.md
2. http://agilityspeaks.com/test.md then redirects to http://agilityspeaks.com/test.html
案例2
1. http://agilityspeaks.dom/test.md redirects to http://agilityspeaks.com/test.html
我没有测试过这个,但是不明白为什么上面的解决方案不起作用。让我知道!
答案 1 :(得分:0)
您可以查看以下给出的示例,我已经给出了4种不同的灯光场景来执行重定向。
$SERVER["socket"] == "10.0.0.14:80" {
server.name = "example.com"
server.document-root = "/data/logs/"
accesslog.filename = "/logs/www/access_log"
server.errorlog = "/logs/www/error_log"
url.redirect = (
"^/(.*)" => "http://tikejhya.com/$1",
"" => "http://tikejhya.com/",
"^(.*[^/])$" => "$1/", --> adding trailing slash
"^(.*.txt)" => "$1" or --> removing trailing slash
)
}
希望这有帮助