【发布时间】:2018-09-13 08:48:04
【问题描述】:
我在使用 Apache(HTTPs 也是)部署 vue 应用程序(没有数据库或服务器端代码)时遇到问题。这是我的 .conf 文件:
<VirtualHost *:80>
ServerAdmin myemail@gmail.com
ServerName mydomain.me
ServerAlias www.mydomain.me
DocumentRoot /var/www/mydomain.me/dist
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/mydomain.me/dist>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =mydomain.me [OR]
RewriteCond %{SERVER_NAME} =www.mydomain.me
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
当我访问 mydomain 时,首页已正确加载(使用 npm run build 构建的 index.html),但是所有路由都不起作用(即 /portfolio)。
但是,如果我将路由器模式从 history 切换到 hash,一切正常 (/#/portfolio),但我想保持 history 模式处于活动状态。
提前致谢!
【问题讨论】:
标签: apache vue.js vue-router