你好,我需要部署React应用程序。
为了实现这个目的,我运行命令:"npm run build"。
之后,在我的vhost.conf文件中,我添加了虚拟主机。
<VirtualHost *:80>
ServerName hello.local
DocumentRoot c:/wamp64/www/hello_world/build
<Directory "c:/wamp64/www/hello_world/build">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
我还在etc/hosts中添加了hello.local
当然,我已经在httpd.conf中启用了mod rewrite
当我运行hello.local/时,我的React应用程序的主页能够正确显示,但是当我想进入react-router路径hello.local/example时,却收到了404未找到错误。请帮忙看看问题出在什么地方?是Apache配置有问题还是React-Router出现了一些错误?谢谢。
index.html
,例如/path/which/does/not/exists/123
,如果我已经使用200响应代码提供了index.html
,那么我无法告诉客户端/path/which/does/not/exists/123
不存在并返回404响应代码。我该怎么处理?我是否被迫使用另一种混合策略,并使用具有服务器端渲染的同构React,还是有一种方法可以在经典的单页应用程序中实现呢? - tonix