I have a Wordpress website where I am using Ajax to display posts in a specific section. I am currently having Javascript add the hash tag like this:
window.location.hash = id;
Everything is working as expected. For instance, it changes the URL to www.mydomain.com/shop/#147. However, if someone visits this link directly, I'd like WordPress to load the corresponding page instead - such as www.mydomain.com/?p=147, which would then convert to something like www.mydomain.com/product/blue-hat with my permalinks structure. This part is what's causing me trouble. Should I use a WordPress rewrite rule for this situation? Or should I make modifications to the htaccess file?
I would appreciate any guidance on how to address this issue. Thank you.