Reputation: 131
Apologies in advance. I'm a beginner with Nginx and have a lot to learn with server administration. After doing a bunch of searching and reading, I'm really not understanding a direct solution to my problem.
With Nginx I have the following URL that awkwardly shows the filepath on my server and the .html extension:
bwillis.info/artifact/faeriefm/faerieFM.html
I'd simply like to be able to access that page with:
bwillis.info/faeriefm
How can I accomplish this? It's my understanding that I'd use the "rewrite" function. But I'm having trouble breaking down and making sense of the syntax on the examples here:
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite
Folder Structure:
index.html sits at the root
Four pages sit one folder deep in folder called "artifact" so: bwillis.info/artifact/samplepage.html
One additional page, the one I used in the example, sits one more folder deep inside the "faeriefm" folder. so: bwillis.info/artifact/faeriefm/faerieFM.html
Server Configuration File:
server {
listen 80;
listen [::]:80;
root /var/www/bwillis.info/html;
index index.html index.htm index.nginx-debian.html;
server_name bwillis.info www.bwillis.info;
location / {
try_files $uri $uri/ =404;
}
}
Upvotes: 1
Views: 1837
Reputation: 49692
You have a number of files located in the folder /var/www/bwillis.info/html/artifact/faeriefm/
. An HTML file called faerieFM.html
and some resource files which appear to be loaded using a path-relative URL.
In order for your path-relative URLs to work correctly, you will need to use a trailing /
in the URI of the original HTML file.
For example:
location /faeriefm {
root /var/www/bwillis.info/html/artifact;
index faerieFM.html;
}
The above example uses a prefix location, as there are a number of URIs beginning with /faeriefm
, including: /faeriefm/
and /faeriefm/javascript.js
. The root
directive ensures that they find the correct folder for the files.
Upvotes: 1