Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React JS virtual host

This is a simple question, but im developer but i know nothing of virtual host, i have an application in ReactJS and its works fine in the homepage www.example.com, but when i go to www.example.com/someword this returned me 404. my 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>

thanks for you help.

like image 585
Kelvins Avatar asked Sep 26 '26 05:09

Kelvins


1 Answers

Actually in react every route such as example.com/something or example.com/something/inside_something should respond back with index.html present inside root folder irrespective of route which has been hit. In apache web servers by default /something means to open something folder in root folder and render index.html from there

try this solution if it works https://gkedge.gitbooks.io/react-router-in-the-real/content/apache.html

like image 50
Anshul Sahni Avatar answered Sep 27 '26 20:09

Anshul Sahni