vue项目打包
打包的文件放在/var/www目录下
此时包括一个index.html和一堆静态文件
修改/etc/apache2下apache2.conf
将AllowOverride None
改为AllowOverride All
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
添加.htaccess文件
和index.html同一级目录下,新建.htaccesss
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
配置rewrite_module
这里因为新版的apache2没有httpd.conf文件
所以修改方式变为
在/opt/etc/apache2/mods-enabled/路径下新建一个文件"rewrite.load",文件内容为"LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so"