-
-
Save joellongie/e6f4a3b5fa98c521782619e487aca15a to your computer and use it in GitHub Desktop.
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteRule ^index\.html$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.html [L] | |
</IfModule> |
@agm1984 God bless you !!
It's probably worth mentioning this needs to be inside a proper <Directory>
directive or apache won't find the existing files/dirs and redirects everything to /index.html
. That's why it wasn't working for me ;-)
Thanks, something I would also add that mod_rewrite must be enabled, you can enable it running
sudo a2enmod rewrite
, and don't forget to restart apache with
sudo service apache2 restart
.
Have a good day
Hi all, Example. It work when I reload https://domain.com/main.
But its die when reload with sub path: https://domain.com/main/sub
Pls help meeee
@vctqs1 you might want to take your question to stackoverflow...
Pretty much you rock for posting this. :) Just migrated servers and react-router-dom was not working. Created a .htaccess
in my web root directory, then added this little jewel to the created .htaccess
file and ba-da-boom, good to go. Thank You!
@Roman-Jordan glad it worked for you!
Thanks, something I would also add that mod_rewrite must be enabled, you can enable it running
sudo a2enmod rewrite
, and don't forget to restart apache with
sudo service apache2 restart
.Have a good day
This solved it for me. Thank you verrry much ! :)
@agm1984 you saved my life. Thanks