Skip to content

Instantly share code, notes, and snippets.

@fulicat
Created May 17, 2019 07:42
Show Gist options
  • Save fulicat/4feb373ac5c67da5e14b33e0b6149c08 to your computer and use it in GitHub Desktop.
Save fulicat/4feb373ac5c67da5e14b33e0b6149c08 to your computer and use it in GitHub Desktop.
NGiNX Configuration for Vue-Router in HTML5 Mode
server {
listen 80 default_server;
listen [::]:80 default_server;
root /your/root/path;
index index.html;
server_name you.server.com;
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
rewrite ^(.+)$ /index.html last;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
# Some basic cache-control for static files to be sent to the browser
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
@fulicat
Copy link
Author

fulicat commented May 17, 2019

location / {
try_files $uri $uri/ /index.html;
}
should do the same (https://router.vuejs.org/en/essentials/history-mode.html) ;-)

@fulicat
Copy link
Author

fulicat commented May 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment