I have a website example.com and I want to serve the following file
/home/myweb/path/file1.html
as
http://example.com/some/spec/path/
It means, when people visit http://example.com/some/spec/path/, they will see the content of the file1.html on that page.
How should I config it?
One solution is to use a specific location to match the URL. The block then contains a root and try_files statement to describe the file to be returned.
For example:
location = /some/spec/path/ {
root /home/myweb/path;
try_files /file1.html =404;
}
The =404 will not be reached if the file exists, but is necessary as try_files requires at least two parameters and in this case /file1.html cannot be the last parameter.
See the location documentation and the try_files documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With