I'm deploying the dist folder of my vue project to an apache server. I'm able to access the app, though the url looks like this: "ip-address/app" which presents a problem when the page is reloaded. I need to have the folder location of the app included in the url to avoid said issue: "ip-address/foldername/app" Do I need to configure this in vue-router or on the server?
答案 0 :(得分:0)
您需要在Apache上配置mod_rewrite
模块。
一种简单的方法是在您部署的文件夹中创建.htaccess
文件,其中包含以下内容:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
该示例文件直接来自vue-router
official docs page。