Update nginx rewrite rules for removing .html extension

This commit is contained in:
fechin committed 2023-03-10 09:27:23 +08:00
1 parent c42b1a86cf
commit 28b8326003
1 file changed
+7 -5
+7 -5
View File
@@ -35,12 +35,14 @@ http {
# Rename cheatsheet
rewrite ^/golang$ /go permanent;
# remove .html extension
location / {
if ($request_uri ~ ^/(.*)\.html) {
return 302 /$1;
}
try_files $uri $uri.html $uri/ =404;
try_files $uri $uri/ @html;
}
location @html {
# remove .html extension
rewrite ^(.*)\.html$ $1 permanent;
try_files $uri.html $uri/ =404;
}
}
}