因為在eagle201510
項目下面有很多子項目,嘗試了多種配置方法都不能共存
我希望是這樣的:
server {
listen 80;
server_name 192.168.10.91;
root "E:/UED/eagle/branch/eagle201510";
location / {
index index.html index.htm index.php;
#autoindex on;
}
location ^~ /m-example/ {
root "E:/UED/eagle/branch/eagle201510/m-example";
try_files $uri $uri/ /index.html =404;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
m-example
目錄是使用vue-router開發的單頁應用,需要單獨配置,但這種方式m-example
並不能正常載入
載入的js,css都變成了htmlconsole
vendors.js:1 Uncaught SyntaxError: Unexpected token <
main.js:1 Uncaught SyntaxError: Unexpected token <
index.html:6 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://192.168.10.91/m-example/dist/main.css".
如果配置改成這樣:
server {
listen 80;
server_name 192.168.10.91;
root "E:/UED/eagle/branch/eagle201510";
location / {
root "E:/UED/eagle/branch/eagle201510/m-example";
try_files $uri $uri/ /index.html =404;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
就正常了。但是其它項目又無法訪問了。 。 。
新增一個
server
配置項目解決,如下:把所有沒有後綴名的請求如果404都跳到index.html