ディスク上のファイルの拡張子index.htmlは ,a.htmlです。http://example.com/ato 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 にすることはできますか?