-1

I have one page which the routing goes from. So if the user go from that root page e.g. http://localhost/rootPage and click on a button to go to http://localhost/rootPage/subPage that's fine however if the user refresh http://localhost/rootPage/subPage it will go the directory listing instead of the subPage.

So I wonder how can I make so the user still ends up in the subPage even though user refresh the page? Is it something in AngularJs or is it something I need to configure on the server?

starcorn
  • 8,261
  • 23
  • 83
  • 124
  • I have same issue and as you said configured on the serverside. – Hadi J Apr 09 '17 at 12:06
  • seems like it is fine if I turn off the html5mode. however it is not possible with html5mode turned on? – starcorn Apr 09 '17 at 12:16
  • Possible duplicate of [htaccess redirect for Angular routes](http://stackoverflow.com/questions/22739455/htaccess-redirect-for-angular-routes) – lin Apr 09 '17 at 12:56
  • @lin Yea I know it is probably a duplicate. Your suggested SO does not solved my problem. Read my answer. Thanks for the minus anyhow ;) – starcorn Apr 09 '17 at 13:33
  • @starcorn it wasn't me. – lin Apr 09 '17 at 13:36

1 Answers1

0

I found many SO answer on my issue. All of them are related to edit .htaccess file. None of them I found solved my issue though, so I googled and found this Youtube video which also involves in editing .htaccess

Here's the snippet of what fixed my problem

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ %{ENV:BASE}index.html [QSA,L]
starcorn
  • 8,261
  • 23
  • 83
  • 124