最初に、URL の末尾に / を追加したかった (lighttpd)
できること
url.redirect = ( "^(.*[^/])$" => "$1/" )
ここで、.txt、png などの一部の拡張子を除外する必要があります。これらの拡張子以外のすべてに末尾のスラッシュを追加したいのですが、うまくいかないようです。
Apache では条件付き書き換えを使用できましたが、lighttpd ではどのようにしますか。
どんな指示でも大歓迎です。
ありがとうございました
Just to make it together this would work (tested)
$HTTP["url"] !~ "^(.*)(\..{3}|/)$" {
url.redirect = (
"^(.*[^/])$" => "$1/"
)
}
@david This would create never ending loop.....
"^(.*)\.(png|txt)$" => "$1.$2",
"^(.*[^/])$" => "$1/"
This will create ever lasting loop
@Matthew This wont quite work as you are pushing everything to %1
$HTTP["url"] !~ "^(.*)(\..{3}|/)$" {
url.redirect = (
".*" => "%1/"
)
}
$HTTP["url"] !~ "^(.*)(\..{3}|/)$" {
url.redirect = (
".*" => "%1/"
)
}
複数のリダイレクト ルールを設定できます。
url.redirect = (
"^(.*)\.(png|txt)$" => "$1.$2",
"^(.*[^/])$" => "$1/"
)
.pngこの場合、リテラルまたはですべてに一致し.txt、元のルールを試してください。