1、前端寫了一套帶有vue路由的的功能。放到nginx配置的目錄下以后,刷新會報404未找到。
這是根據實際情況來寫的。
location /h5/activity/wechat/ {
index index.html index.htm index.php;
try_files $uri $uri/ /h5/activity/wechat/index.html;
}
這是項目直接放在根目錄下的情況。
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.html;
}
2、nginx路由規則配置
location / {
index index.html index.htm index.php l.php;
autoindex off;
try_files $uri $uri/ /index.php?$query_string;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php last;
break;
}
}
location / {
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^/api/(.*)$ /api.php?s=$1 last;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?s=$1 last;
}
}