2012-03-10 67 views
0

我擁有兩個重定向我的應用程序,Lighttpd的多重定向

$HTTP["host"] =~ "^(.*)$" { 
    url.redirect = ("^/(.*)\.(markdown|md)$" => "http://%1/$1.html") 
} 

$HTTP["host"] =~ "^www\.(.*)$" { 
    url.redirect = ("^/(.*)" => "http://%1/$1") 
} 

一個重定向降價或MD擴展HTML版本,其他WWW重定向到非WWW。但一個取決於哪一個來自後者。

+0

是的,那是預期的行爲。這裏有個問題嗎? – 2012-06-08 17:30:14

回答

0

如果你翻轉重定向的順序,那麼你應該達到預期的結果。

$HTTP["host"] =~ "^www\.(.*)$" { 
     url.redirect = ("^/(.*)" => "http://%1/$1") 
} 
else $HTTP["host"] =~ "^(.*)$" { 
     url.redirect = ("^/(.*)\.(markdown|md)$" => "http://%1/$1.html") 
} 

CASE 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 

CASE 2

1. http://agilityspeaks.dom/test.md redirects to http://agilityspeaks.com/test.html 

我沒有測試過這一點,但不明白爲什麼這上面的解決方案是行不通的。讓我知道!

0

你可以查看下面給出的例子,我已經給lightty 4 diff diffario執行重定向。

$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 
      ) 
    } 

希望這有助於