react使用BrowserRouter部署到docker的httpd刷新页面报错Not Found(404)解决方案
文章目录
- 找到
httpd.conf配置文件(/usr/local/apache2/conf) - 进入编辑
- 找到
#LoadModule rewrite_module modules/mod_rewrite.so这一行并取消注释 - 找到所有的
AllowOverride,将默认值none修改为All(大约有三处,不要漏) - 在项目根目录(
/usr/local/apache2/htdocs)新建.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>保存后退出。
- 重启http容器

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论