Website is not loading on server while refresh it from browser in angular 2

624 views Asked by At

I am unable to reload my website when refresh from browser in angular 2

  1. I don't want hash '#' symbol in url thus remove it from routing use hash
  2. redirect to same page from app.component from getting active url

Not Found The requested document was not found on this server. Web Server at someserver.com

2

There are 2 answers

1
Eliran Eliassy On

Sounds like you need to config on the server that every route will be responses with the index.html.

0
Sachin Shah On

1) For remove, hash please check this

2) For reloading issue, You have two options.

I) Use .htaccess and set the path in that 
II) Allow you dist folder from node. 

Smple .htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /{{project folder name}}/ [NC,L]