ディスク上のファイルの拡張子index.html
は ,a.html
です。http://example.com/a
to load/var/www/a.html
とhttp://example.com/
to loadのリクエストが必要です/var/www/index.html
。他の URL を正規の URL にリダイレクトするhttp://example.com/a.html
必要があるため、にリダイレクトする必要がありhttp://example.com/a
ます。
私の構成は次のようになります。
rewrite ^(/.+)\.html$ $scheme://$host$1 permanent;
location / {
root /var/www;
try_files $uri.html $uri $uri/ =404;
}
これはリダイレクトさ/a.html
れ、ディスクから/a
のロードに成功します。a.html
$ curl -D- -s http://www.jefftk.com/food.html | grep ^Location
Location: http://www.jefftk.com/food
$ curl -s http://www.jefftk.com/food | grep ^Location
しかし、それはに送信/
し/index
ます:
$ curl -s -D- http://www.jefftk.com/pictures/ | grep ^Location
Location: http://www.jefftk.com/pictures/index
$ curl -s -D- http://www.jefftk.com | grep ^Location
Location: http://www.jefftk.com/index
書き換えルールを削除すると、からのリダイレクトが停止/a.html
しますが、への/a
送信も停止/
し/index
ます:
$ curl -D- -s http://www.jefftk.com/food.html | grep ^Location
$ curl -D- -s http://www.jefftk.com/food | grep ^Location
$ curl -D- -s http://www.jefftk.com/ | grep ^Location
$ curl -D- -s http://www.jefftk.com/pictures/ | grep ^Location
なぜこれが起こるのでしょうか?.html
両方の必要なもの (拡張子なしindex
、URL なし) を同時にnginx にすることはできますか?