Wednesday, September 5, 2018

Lighttpd and Vue.js Router History Mode Server Configuration

So lighttpd isn't listed as one of the server configurations on this page of Vue's documentation nor could I find a solution on Google, so I figured I would put it here in case anyone is looking for it in the future.

url.rewrite-if-not-file = (
     "/.*" => "/index.html"
)

The key is using url.rewrite-if-not-file. If you don't and instead use url.rewrite-once then even your js, css, etc. will be routed to the index.html file causing your app to request it instead of your actual js, css, etc.

Put this in your vhost configuration, or your lighttpd.conf at /etc/lighttpd/.