Vue-router on apache, SPA in sub-directory, can only access pages by redirect

前端 未结 3 555
陌清茗
陌清茗 2021-02-04 17:58

So I have a Vue app for a client set up on an apache dev server. I am doing this to match the production environment. The app is in a subdirectory and I set the \'base\' option

3条回答
  •  旧时难觅i
    2021-02-04 18:44

    Jeez, was looking for a solution to this for a good chunk of time yesterday and today and just found the answer: Vue help forum: Vue webpack project path change

    Relevant code for anyone else that my find this:

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

    I honestly tried something similar yesterday. I changed the RewriteBase to the subdir but not the rewrite rules! I'm bad at .htaccesss stuff :(

提交回复
热议问题