Redirecting ?replytocom so bots go home

Earlier this month I noticed that a particular bot that likes to visit my website, “MJ12bot/v1.4.8” seems to be particularly attracted to the “reply to comment” links generated by my blog. Those are links that bots see, but we see the “Reply” button that uses JavaScript to reply to a comment.

To be honest, it’s pretty annoying to see a bot constantly fetching those URLs from my website. Earlier this month, it was on a roll and grabbing several dozen at a time. While my server can handle the traffic without any issues, who wants a bot trampling over their server?

I decided to stop them in two ways:

  • Redirect them back to the post in a mod_rewrite rule.
  • Block them in robots.txt and hopefully the bots will go away.

Coming up with a mod_rewrite rule was surprisingly hard, but after mentioning this on Mastodon I received a reply from Jos Klever who figured out I needed the QSD flag. So, to spare you the hassle of researching it, here are the mod_rewrite rules that worked for me. It causes a 301 permanent redirect to the anchor tag of the comment. Add this to your .htaccess file.

RewriteCond %{QUERY_STRING} replytocom=(.*)$
RewriteRule ^(.*)/          $1/#comment-%1 [NE,QSD,L,R=301]

Blocking requests like this in the robots.txt is much simpler. WordPress can generate the robots.txt file for you using the robots_txt filter. Add the following to a mu-plugin PHP script.

function disallow_replycom_urls( $output, $public ) {
    $output .= 'Disallow: ?replytocom';
    return $output;
}
add_filter( 'robots_txt', 'disallow_replycom_urls', 10, 2 );

I haven’t received many comments on my posts lately. However, I stumbled upon some interesting posts by clicking the RANDOM link above, which I decided to examine as part of my research. During my search, I delved deep into the blogosphere of the past, almost like being an archaeologist, because some links were no longer available, and I had to search for them on archive.org. I was also pleasantly surprised to find that a link to a GIF from 2005 was still alive!

How to: a keyboard shortcut to lock your Mac

For many years, I was using a hot corner to lock the screen of my Mac, but I always wished there was the equivalent of Windows-L in Windows to do it.

I have no idea when this keyboard shortcut was added, but tapping the CTRL-CMD-Q shortcut will lock your Mac screen. Apparently, if you have a small magic keyboard, then CTRL-Shift-Eject will do the job too. This Stack Exchange Question shows the shortcut wasn’t available in 2015. Users had to resort to all sorts of tricks to lock their screen with the keyboard. An updated answer from 2019 reveals the shortcut, so I guess it’s at least four years old.

An apple on the side of the road
An apple on the ground. Like shortcuts, you never know what you’ll find.

Hot corners are great and all, but I’ve had so much trouble making sure the cursor stayed in the corner. I’d watch to make sure my mouse didn’t move, and the screen remained locked. Otherwise, I turn my back, I’m heading out the door and the screen lights up again!

Loads more keyboard shortcuts here if you’re interested in that sort of thing. That page may also explain why something strange happened on your computer while you were typing into the wrong window and changed a Finder setting, for instance.

Have fun getting locked.

GraXpert fixes your Astro shots

Hot off my RSS feeds is GraXpert which I found through this Fstoppers article. It corrects colour tints and gradients in astrophotography shots. I don’t do much astrophotograpy:

  1. late nights
  2. cloudy nights
  3. clear nights are cold

But when I do, I get colour tints from nearby towns and cities, or I add it myself thinking it looked better. I’m still very much a newbie when it comes to this sort of thing. Anyway, here is a Milky Way photo I took in Tenerife last year. I thought it came out pretty well, despite my attempts to make it look better.

The Milky Way, viewed from the volcano on Tenerife Island.

From March to the end of August is the best time to shoot the Milky Way in Ireland, and I have to admit I rarely ventured out to try this sort of photography since taking that photo in Tenerife. So, when I read about GraXpert that was the photo that sprang to mind. I loaded the original tiff file into it, pressed the “Create Grid” button, and then hit the “Calculate Background” button. I’m rather pleased with the results!

The GraXpert Grid
The Milky Way, viewed from the volcano on Tenerife Island.

I did no other work with this, which is why you can see the foreground, but even so, it got rid of that green colour cast in the sky.

GraXpert is free, open source software. It’s not a plugin of Lightroom or Photoshop, but it’s easy to generate a TIFF file for Photoshop from Lightroom, and then open it in an external programme. It’s definitely worth a try if you have any astro photos you need to work on.