【发布时间】:2019-01-08 14:09:55
【问题描述】:
我无法让我的 create react 应用程序构建正确路由到我服务器上的组件。
我有一个 .htaccess 文件
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]
所以它总是路由到我的 index.html
我网站的网址是 .com/project,我的 package.json 文件中的主页选项是 homepage: '/project'
我已经无事可做。
因为我的 htaccess 它总是路由到我的 index.html 但路由器总是加载 404 组件。我错过了什么。
【问题讨论】:
标签: reactjs apache react-router create-react-app