#Error 404 when refreshing page

5 messages · Page 1 of 1 (latest)

night dagger
#

I'm currently hosting my angular website on hostinger but I have a problem. The website works fine until I refresh a page. For example: I go to mywebsite.com/about. It works fine until i refresh. When I refresh I get Error 404 not found. The root of the problem seems to be with it being a SPA (single page application).

If anyone has had the same issue or similar with other hosting providers, please let me know!

night dagger
#

Fixed it! In my case, using hostinger, I just created the file .htaccess.

#

`RewriteEngine On

If an existing asset or directory is requested go to it as it is

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]

If the requested resource doesn't exist, use index.html

RewriteRule ^ /index.html`

#

The code above pasted inside .htaccess