I have a single page application - which means everything on the server gets redirected to a single index.html
file which does the heavy lifting and routing using the HTML5 history api (pushstate).
Now, I want to add a new landing page to the side - let's call it landing.html
and I want clients to first get to landing.html
when they access /
and index.html
if they access any other route.
Now IE9 does not support the HTML5 history API, so using "hash urls" paths like /books/authors
become /#!/books/authors
in it. Since the hash section of the URL is not sent to the server as far as the server is concerned all paths are /
which means I can't route to landing.html
or index.html
based on that logic.
I've thought of a hack - redirecting URLs with /
to landing.html
, detecting #!
on the client, adding a cookie on the server (or client) called notReallyHomePage
and redirecting to the correct page based on the cookie on the server. This is really hacky and not a good solution.
What would be the correct way to deal with routing in this case?
My backend is in ASP.NET MVC but I don't think that's relevant to the question