Skip to content

Instantly share code, notes, and snippets.

@hernandev
Created December 8, 2017 07:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hernandev/c4f647b76aa7ec8b301b53bf8bd493f2 to your computer and use it in GitHub Desktop.
Save hernandev/c4f647b76aa7ec8b301b53bf8bd493f2 to your computer and use it in GitHub Desktop.
Vue.JS redirect history mode URL's to hash mode URL's. (Using Nginx)
server {
listen 80 default_server;
listen [::]:80 default_server;
root /web;
index index.html;
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
# old history mode rewrite configuration, now disabled.
# rewrite ^(.+)$ /index.html last;
# when using hash mode, use this line to auto append the /#/ on the URL's
# choose between 301 and 302 based on your preference.
return 302 $scheme://$http_host/#$request_uri;
}
location ~* \.(?:ico|css|ttf|woff|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";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment