Nginx
Nginx hints / aide
Mon objectif était :
- Si on tape l’URL sans le
/à la fin, il redirige en ajoutant le/à la fin - Si on tape l’URL avec le
/à la fin, tout doit fonctionner - Tout ne doit être que statique et les fichiers doivent obligatoirement exister, sauf
index.htmletindex.htm - Filtre “custom” avec
/à la fin. Si oui, n’accepter queindex.htmlouindex.htm - Filtre “custom” en ignorant le
/à la fin. Si oui, le nom, qui doit être forcément un fichier, sinon, rediriger en ajoutant un/pour qu’il reboucle au début
J’en suis donc arrivé à ces règles, plus “proches” de la configuration possible dans Nginx :
location ~* ^/unity/(?<p>.+)/$ {
root /web/htdocs/unity;
try_files /$p/index.html /$p/index.htm /$p =403;
access_log off;
expires 1h;
}
location ~* ^/unity/(?<p>.+) {
root /web/htdocs/unity;
try_files /$p $p @redirect_with_slash_at_the_end;
access_log off;
expires 1h;
}
location @redirect_with_slash_at_the_end {
return 301 $scheme://www.mywebsite.com$request_uri/;
}