[Vuejs]-Config nginx for Vue.js distribute project

0๐Ÿ‘

I need to configurate URL Rewrite

you can try this

location ~* \.(gif|jpg|jpeg|png|css|js|ico)$ {
    root <your static file root>
}
location / {
    return 200 /index.html
    # or use rewrite
    rewrite ^.*$ /index.html
}

Or use some server code that has route like node , asp.net core to send your html

0๐Ÿ‘

Follow my settings of single-page application config in Nginx:

server {

    listen 80;
    server_name qy.abc.xyz;

    #access_log /var/log/logs/qy.abc.xyz.access.log  main; 

    charset utf-8;

    index index.html;
    root /data/ldl/repo/vue_user_site/dist;


    location / {
       try_files $uri $uri/ @rewrites;

    }

    location @rewrites {
        rewrite ^(.+)$ /index.html last;
    }

    location = /50x.html {
        root   /usr/share/nginx/html;
    }

}

Leave a comment