前端 - 單頁應用nginx配置
我想大声告诉你
我想大声告诉你 2017-05-16 17:23:07
0
1
525

我有網站www.a.com
我希望訪問www.a.com/**,
除了www.a.com/api/**的時候直接顯示index.html
我的配置如下:

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;
    }
}

現在遇到的問題是,
當我透過網址列輸入www.a.com/page1的時候,
我希望直接返回www.a.com/index.html,
但是現在卻回傳404!

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

全部回覆(1)
淡淡烟草味

這個應該用rewrite
if($request_uri !~ ^api/.*){
rewrite $1/index.html break;
}

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!