So I learned from this handy guide how to use .htaccess to redirect pretty URIs like foobar.com/baz to specific content that may reside at foobar.com/bazheader345.php?user=baz.
What if I’d like to do the opposite? My anchors are static but I have a lot of content in different files – and none of them has a particularly pretty name. Say I have a page at foobar.com called 123.html and would like the location bar to remain http://foobar.com despite the navigation between files that the user does.
Can this be done via changes to .htaccess? Or simply Javascript?
If it is possible, would it interfere with the browser’s history states?
This is really easy to do with HTML frames. Let’s say your home page is
http://example.com/index.html. Saveindex.htmlashome.htmland save something like the following inindex.html:If you don’t want to rename your original home page, you could instead stick a
DirectoryIndexdirective in your.htaccessfile. Just save the above code in, say,frame.html, changehome.htmlto whatever filename your index is at, and add:to your
.htaccessfile.However, you should know that this practice fell out of style over 10 years ago because it has inherent problems. It won’t break your history, but it breaks deep linking (that is, one can’t bookmark or link to anything other than the home page).
More info: