【问题标题】:React JS virtual hostReact JS 虚拟主机
【发布时间】:2018-01-26 07:55:25
【问题描述】:

这是一个简单的问题,但我是开发人员,但我对虚拟主机一无所知,我在 ReactJS 中有一个应用程序,它在主页 www.example.com 中工作正常,但是当我去 www.example.com/这让我返回了 404。我的虚拟主机配置:

<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>

感谢您的帮助。

【问题讨论】:

    标签: reactjs apache2 virtualhost


    【解决方案1】:

    实际上,在响应每条路由(例如example.com/somethingexample.com/something/inside_something)时,无论路由已被击中,根文件夹内都应使用 index.html 进行响应。默认情况下,在 apache web 服务器中 /something 意味着在根文件夹中打开 something 文件夹并从那里渲染 index.html

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

    【讨论】:

      猜你喜欢
      • 2010-10-07
      • 1970-01-01
      • 2019-03-22
      • 2014-09-08
      • 2012-05-27
      • 2021-02-10
      • 2011-06-19
      • 2014-11-12
      • 1970-01-01
      相关资源
      最近更新 更多