Skip to content

Instantly share code, notes, and snippets.

@innomatrix
Forked from hernandev/nginx.conf
Created November 5, 2020 23:51
Show Gist options
  • Save innomatrix/6aa40d3cf186a4aa7485d5d8e187df10 to your computer and use it in GitHub Desktop.
Save innomatrix/6aa40d3cf186a4aa7485d5d8e187df10 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