問題現象:
訪問 nginx 的url 后面的路徑不加 /訪問不到頁面 ,返回404
配置如下:
...
server xxx;
listen 80
location /asdf/company {
root /usr/share/nginx/html;
if (-d $request_filename){
rewrite ^/(.*)([^/])$ $scheme://$host:30091/$1$2/ permanent;
}
}
...
配置說明
通過配置
if (-d $request_filename){
rewrite ^/(.*)([^/])$ $scheme://$host:30091/$1$2/ permanent;
}
判斷url 是否帶有/ 如果沒有就添加即可。
注意location 的路徑后面不加/ , 否則如果url 不加/ 那么就404