乐趣区

React-router BrowerRouter 刷新404 Apache服务器解决办法

1. 找到 etc/apache2/sites-availables/000-defautl.conf 配置文件
2. 添加以下配置

<VirtualHost *:80>

<Directory “/var/www/html/”>

Options Indexes FollowSymLinks

AllowOverride all

Require all granted

</Directory>

</VirtualHost>

3. 重新 apache 服务器
4 在项目文件根目录下,添加.htaccess 文件,加入如下规则

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^.*$ / [L,QSA]

5. 参考链接

退出移动版