Comment supprimer toutes les extensions .html ainsi que toutes les occurrences de index.html d'une chaîne d'URL dans Nginx ?
http://www.mysite/index.html
a http://www.mysite
http://www.mysite/articles/index.html
a http://www.mysite/articles
http://www.mysite/contact.html
a http://www.mysite/contact
http://www.mysite/foo/bar/index.html
a http://www.mysite/foo/bar
EDIT : Voici mon fichier de configuration :
serveur {
listen 80;
server_name staging.mysite.com;
root /var/www/staging.mysite.com;
index index.html index.htm;
access_log /var/log/nginx/staging.mysite.com.log spiegle;
#error_page 404 /404.html;
#error_page 500 503 /500.html;
rewrite ^(.*/)index\.html$ $1;
rewrite ^(/.+)\.html$ $1;
rewrite ^(.*/)index\.html$ $scheme://$host$1 permanent;
rewrite ^(/.+)\.html$ $scheme://$host$1 permanent;
location / {
rewrite ^/about-us /about permanent
rewrite ^/contact-us /contact permanent;
try_files $uri.html $uri/ /index.html;
}
}