Hello I am trying to upload static html files in Centos. So far I created subdomain and set nginx to open specific static html when It gets hit by browser. So far so good, problem is when I try to navigate from that static html to another html with relative paths say
Go elsewhere
it does not work. I get redirected to my whateveraddress/differentFolder/index.html but nginx says 404 Not Found. Is there a way to be able to redirect to another pages within the html files or I have to register every route in nginx?
nginx config:
server {
listen 80;
server_name domain.tk www.domain.tk;
root /home/apps/html/one;
location / {
index index.html;
}
}
2
Answers
I found the solution after reading nginx documentation, it was to construct nginx.config like so:
The thing is what if, I have 100 posible routes, this way I must specify all in the config?
There are probably a few different ways to do this, but one option is to use the NGINX map directive, as the example below, adding additional URI locations to the map block and leaving the server block untouched.