Kelvins
Kelvins

Reputation: 49

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.

Upvotes: 3

Views: 8061

Answers (1)

Anshul Sahni
Anshul Sahni

Reputation: 666

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

Upvotes: 3

Related Questions