mastodon.ie is one of the many independent Mastodon servers you can use to participate in the fediverse.
Irish Mastodon - run from Ireland, we welcome all who respect the community rules and members.

Administered by:

Server stats:

1.6K
active users

Donncha Ó Caoimh

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 htaccess.madewithlove.com/

I don't have a solution (yet) for the #, but I'm still searching...

htaccess testerhtaccess tester ♥ madewithloveEasily test your htaccess rewrite rules

@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: htaccess.madewithlove.com?shar

It works for homepage and subpages.

htaccess testerhtaccess tester ♥ madewithloveEasily test your htaccess rewrite rules

@JosKleverWebSupport Oh, that's great!

I had to make one final change to that rewrite rule as the anchor is actually "-XXXX"

Thanks! Blog post going up later and I'll link to your site.