How do I make the redirects in go_router
package work correctly when uploading the website to cPanel? For example when I type in the url www.website.com/contact
I need it to open the /contact
route on my app. It works great when hosting locally and when I host it to Firebase with the rewrites file (https://stackoverflow.com/a/71956918/12099062), but I am unable to make the redirects work in cPanel.
I have tried configuring the Redirects in cPanel, but if I redirect any page to www.website.com
it just moves to the main page and if I redirect it to www.website.com/index.html
it just shows Exception: Bad State: No Element
.
Any help is really appreciated!
I managed to make it work by following a React app tutorial (Deploy / Host your React App with cPanel in Under 5 Minutes). I needed to manually add these contents to the .htaccess
file in cPanel File Manager public_html
folder (Note: You need to enable "Show hidden files" in order to see that file and if it does not exist, just create it).
Here is the complete .htaccess
file:
<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>