修改httpd.conf
#启用rewrite 模块
LoadModule rewrite_module modules/mod_rewrite.so
#修改Directory网站目录配置的子项,增加如下,启用.htaccess
<Directory "/usr/local/apache2/htdocs">
Options Indexes FollowSymLinks
#Options FollowSymLinks AllowOverride All
AllowOverride All
Order allow,deny
Allow from All
Require all granted
</Directory>
#在网站根目录创建.htaccess文件与配置
Options +FollowSymLinks -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d #拒绝目录
RewriteCond %{REQUEST_FILENAME} !-l #快捷方式
RewriteCond %{REQUEST_FILENAME} !-f #拒绝文件
RewriteCond %{REQUEST_URI} !index\.html #防止死循环
RewriteRule (.*) index.html?$1 [L,QSA,R]
重启apache即可。