i’m building a site with lots of subpages but very little content. So I decided to do a one-pager.
My default.php template renders all content into containers with their uid as classes. Only one container is visible at a time. This is determined by a simple javascript that computes the location.hash of the URL. All cross links on the site get their http://kirby.tld replaced with http://kirby.tld/# when rendered… works pretty well so far.
I think it is possible to configure Apache in a way, that it translates a “regular” path into a hashed path. But I can’t find a way to add the code I found to the default Kirby .htaccess
I would like to have this option for the backend’s page “Preview” functionality and also as a backup when somebody shares a link without the hash. And because I’m curious
Hope anyone can help me with that – have a great weekend,
Hans
The NE flag is key here, in order to instruct the htaccess rewrite engine to not escape special characters in the target URL. So, say you have three “subpages” (products, company, and contact):
Untested. You probably have to list those UIDs here, as a more generic regex would likely get triggered on too many URLs that actually have to keep working as they are (like all the media, plugins, panel etc. stuff). If you want to have it fully dynamic, setting up a custom route that catches all the subpages’ UIDs, in combination with go(), is maybe the more flexible way than htaccess.
Personally, I’d probably go with a 302 redirect, as I understand these are anyway just fallbacks not actively promoted URLs. With 301, those URLs would essentially be “burnt” forever, in case you later want to switch to a website with “real” subpages.