apache.htaccessvue.jsvuejs2vue-router

Setting up .htaccess rewrite rules for VUE-JS SPA


I have a VUE application that is using the VUE Router in History mode and can not seem to get it working on my production server. I have setup the .htaccess file using the settings given in the documentation:

  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]

This seems to work fine for the front end; aka (www.url.com/Anything/anything) seems to get routed properly.

The issue comes when I am trying to route to my admin:

www.url.com/admin/dashboard 

This is setup as route with a child route in my index.js but I think I need to set up something special in my .htaccess as well however I can't seem to find anything about how to do this. Thank you in advance for any help.


Solution

  • This is what my hosting company changed my .htaccess file to that worked for me.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{ENV:HTTPS} !on [NC]
    RewriteRule ^(.*)$ https://myURL.com/$1 [R,L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . index.html [L]