React JS虚拟主机

时间:2017-08-17 18:50:37

标签: reactjs apache2 virtualhost

这是一个简单的问题,但我是开发人员,但我对虚拟主机一无所知,我在ReactJS中有一个应用程序,它在主页www.example.com上运行良好,但是当我去www.example.com/时someword这让我回复了404.我的vistual host conf:

<VirtualHost *:80>
    ServerName somepage.com
    ServerAlias somepage.com www.somepage.com
    DocumentRoot "/var/www/somepage/build/"
    DirectoryIndex index.html
<Directory "/var/www/somepage/build/">
    AllowOverride All
    Order allow,deny
    Allow from All
</Directory>
ErrorLog /var/log/apache2/somepage_error.log
CustomLog /var/log/apache2/somepage_access.log combined
</VirtualHost>

谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

实际上,每个路由(例如example.com/somethingexample.com/something/inside_something)都应该响应index.html存在于根文件夹中,而不管路由被击中。默认情况下,在apache Web服务器中/某事意味着在根文件夹中打开something文件夹并从那里呈现index.html

尝试此解决方案,如果它有效https://gkedge.gitbooks.io/react-router-in-the-real/content/apache.html