Created
September 7, 2016 00:36
-
Star
(173)
You must be signed in to star a gist -
Fork
(49)
You must be signed in to fork a gist
-
-
Save alexsasharegan/173878f9d67055bfef63449fa7136042 to your computer and use it in GitHub Desktop.
Apache Config for React Router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteRule ^index\.html$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-l | |
RewriteRule . /index.html [L] | |
</IfModule> |
If your getting error 404 when your refresh or try to route to another
To solve it esure to put htaccess then edit your conf file in sites available of apache
htaccess put this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
then cd /etc/apache2/sites-available/
then sudo nano react.conf
in your conf ensure toi make sure u add this in ur conf
AllowOverride All
eg
<VirtualHost 172.31.47.186:80>
ServerAdmin [email protected]
DocumentRoot /var/www/nicedashboard
# Relax Apache security settings
<Directory /var/www/nicedashboard>
AllowOverride All
Allow from all
Options -MultiViews
Require all granted
</Directory>
</VirtualHost>
after
apache2ctl configtest
sudo service apache2 restart
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Nginx add / merge the following in your nginx config file
location / {
try_files $uri $uri/ /index.html;
}