It's surprisingly hard to redirect from URL/?replycom=XXXX to URL/#XXXX
The following rule redirect to URL/ but miss out the anchor tag. The hash character gets encoded unless you add [NE] but then "?" doesn't remove the query parameter. I bet I'm missing something pretty obvious.
RewriteCond %{QUERY_STRING} replytocom=(.*)$
RewriteRule ^(.*)/ $1/? [L,R=301]
@donncha The first issue is the mix of replycom and replytocom.
A nice tool to test various ideas is https://htaccess.madewithlove.com/
I don't have a solution (yet) for the #, but I'm still searching...
@JosKleverWebSupport Thanks, I was using that site to test this and it's invaluable. The hash character problem is an annoying one. I might just create a simple mu plugin that redirects. The redirect to / is a huge improvement, and it's only search bots requesting those ?replytocom URLs anyway.
@donncha I think I've found the solution! Use the QSD flag to discard the query string in the output. You can see it working here: https://htaccess.madewithlove.com?share=fe40d630-cdf3-4374-85bb-645f71ad6c51
It works for homepage and subpages.
@JosKleverWebSupport Oh, that's great!
I had to make one final change to that rewrite rule as the anchor is actually "#comment-XXXX"
Thanks! Blog post going up later and I'll link to your site.