vue.js - nginx configuration after vue-router turns on HTML5 history mode
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-16 17:15:13
0
2
1064

Because there are many sub-projects under theeagle201510project, 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-exampleThe directory is a single-page application developed using vue-router and needs to be configured separately, but this waym-examplecannot be loaded normally
js and css have become html
console

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. . .

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all (2)
过去多啦不再A梦

Add aserverconfiguration item to solve the problem, as follows:

server { listen 80; server_name www.m-example.com; root "E:/UED/eagle/branch/eagle201510/m-example"; location / { try_files $uri $uri/ /index.html =404; } }
    过去多啦不再A梦

    Jump to index.html for all requests without suffix if 404

    location / { error_page 404 /index.html; }
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!