Front-end - single-page application nginx configuration
我想大声告诉你
我想大声告诉你 2017-05-16 17:23:07
0
1
523

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!

我想大声告诉你
我想大声告诉你

reply all(1)
淡淡烟草味

You should use rewrite for this
if($request_uri !~ ^api/.*){
rewrite $1/index.html break;
}

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!