@Dexilez
It really depends on your application and how it’s configured to handle requests, more specifically:
The most basic way to handle this would be to use try_files
in the location
block. Keep in mind, this will rewrite ALL URI’s and attempt to match each request to an existing HTML file. If that file does not exist, an error will result (more specifically, a 500 error). With this in mind, it’s important that you setup your error pages as well and not exclusively rely on this location block (example of this below as well).
Working Example
location / {
try_files $uri $uri/ $uri.html;
}
This will allow:
.... where anyactualfile
= anyactualfile.html
.
–
To setup the error files, you’d place the following above your location block:
error_page 404 /error_404.html;
error_page 500 /error_500.html;
error_page 503 /error_503.html;
...
...
...
resulting in:
error_page 404 /error_404.html;
error_page 500 /error_500.html;
error_page 503 /error_503.html;
location / {
try_files $uri $uri/ $uri.html;
}
–
Relying on this type of rewrite also affects directories, too. So if a request comes through such as:
.... and the directory /me/
does not exist, an error will result, so you’ll need to be able to handle them by creating potential the directories.