Because there are many sub-projects under theeagle201510
project, I have tried multiple configuration methods but they cannot coexist
I hope it is like this:
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
The directory is a single-page application developed using vue-router and needs to be configured separately, but this waym-example
cannot be loaded normally
js and css have become 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".
If the configuration is changed to this:
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; } }
is normal. But other projects are inaccessible. . .
Add a
server
configuration item to solve the problem, as follows:Jump to index.html for all requests without suffix if 404