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/.

3 comments:

  1. Hi, thank you for posting this. It's the only recource i've found for this issue. However I'm having trouble with this... What is your vhost configuration and how did you connect it to this setting? I'm not sure what's the base for both the URLs you have to provide...
    Thank You in advance

    ReplyDelete
    Replies
    1. Nervermind. It's right and complete the way you wrote it. I just forgot to include "mod_rewrite" in the config. :)

      I will probably make a Pull Request for the documentation to add lighttpd on the site you mentioned...

      Delete
  2. This is huge help thank you!

    ReplyDelete