React JS 虚拟主机
React JS virtual host
这是一个简单的问题,但我是开发人员,但我对虚拟主机一无所知,我在 ReactJS 中有一个应用程序,它在主页上运行良好 www.example.com,但是当我转到 www.example.com/someword 这返回了我 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>
感谢您的帮助。
实际上,在反应中,每条路由(例如 example.com/something
或 example.com/something/inside_something
都应使用根文件夹中存在的 index.html 进行响应,而不管已命中的路由如何。在 apache Web 服务器中,默认情况下 /something 意味着打开根文件夹中的 something
文件夹并从那里呈现 index.html
尝试此解决方案(如果有效)https://gkedge.gitbooks.io/react-router-in-the-real/content/apache.html
这是一个简单的问题,但我是开发人员,但我对虚拟主机一无所知,我在 ReactJS 中有一个应用程序,它在主页上运行良好 www.example.com,但是当我转到 www.example.com/someword 这返回了我 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>
感谢您的帮助。
实际上,在反应中,每条路由(例如 example.com/something
或 example.com/something/inside_something
都应使用根文件夹中存在的 index.html 进行响应,而不管已命中的路由如何。在 apache Web 服务器中,默认情况下 /something 意味着打开根文件夹中的 something
文件夹并从那里呈现 index.html
尝试此解决方案(如果有效)https://gkedge.gitbooks.io/react-router-in-the-real/content/apache.html