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?
CodePudding user response:
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.