I have a website www.a.com
I want to visit www.a.com/**,
Except when www.a.com/api/**, index.html
is displayed directly.
My configuration is as follows:
server {
listen 80;
server_name www.a.com;
location /api {
proxy_pass http://localhost:8080/api;
proxy_set_header Host $http_host;
}
location / {
root /usr/share/nginx/weather;
index index.html index.htm;
}
}
The problem we are encountering now is,
When I enter www.a.com/page1 through the address bar,
I want to return directly to www.a.com/index.html,
But now it returns 404!
You should use rewrite for this
if($request_uri !~ ^api/.*){
rewrite $1/index.html break;
}