I had really a simple site written in PHP that I have just rewritten into a single-page HTML only solution (using #-sections).
Now I would like to map the old querystrings used to new hash-based URLs instead. That would mean that for example ?id=itemA should become #newAndImprovedItemA (the old ids are not the same as the new hashes, yet since there are only four possible values, it shouldn’t be too much work to manually map them I guess). Apparently this is not working with a simple RedirectPermanent, but from what I understand I have to use RewriteRules. Unfortunately I don’t have any experience with that at all, so I wasn’t able to come up with anything that is properly working yet.
At the moment I am using:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=itemA$
RewriteRule ^index.php$ /#newAndImprovedItemA [L]
which will redirect me to the new index.html, but will not add the hash. Honestly, I do not have too much of a clue what that code is supposed to do, so it might be way off (bear with me in that case), yet I am unfortunately not able to understand what people are writing in other posts regarding that topic.
What would be a simple possibility to just map index.php?id=itemA to #newAndImprovedItemA ?
Hashes are a purely client-side operation. Your rewrite is only doing an Apache internal-only redirect, without affecting the client at all. You’d have to force a full-blown HTTP 30x redirect, e.g.
which would round-trip through the client. The downside to this is it’ll cost you another HTTP request cycle, and change the address in the user’s address bar.