I know about setting and getting URL parameters, e.g. example.com/index.html?x=foo&y=bar&z=hello would give your javascript access to the x, y, and z variables specified in the URL.
What I wish for is the same behavior but utilizing the file path part of the URL. E.g. example.com/index.html/foo/bar/hello.
How can I accomplish this? In particular,
- How can I make sure the browser knows to go to
index.htmleven though the file pathindex.html/foo/bar/hellowas specified? - How can I update the URL to
example.com/index.html/foo/bar/world, such that if I press "Back" on the browser, it will go back toexample.com/index.html/foo/bar/hello.
Furthermore, I'd heavily prefer if the solution was in pure javascript/html, without reliance on jquery or any other libraries.
/foo/bar/hello.should be a file to access it.index.htmlwas a url hash value ....example.com/index.html#/foo/bar/hello. Server would only knowindex.htmland your front end could parse the hash to do whatever is needed fromlocation.hashwindow.history.pushState({x: "foo", y: "bar", z: "hello"}, "", "/foo/bar/hello"), with navigation working fine and everything. The only thing is that directly entering the urlexample.com/index.html/foo/bar/hellowon't work properly. You're saying the only way the URL could work properly is messing with the server side, then?