Blocking a domain from accessing my website (Apache)

I checked GoatCounter recently and noticed a lot of “visits” from a sketchy website. I tried to configure Apache to block them, but they continue to “visit” multiple times a day. Even if they’re harmless, I’d rather not have my page views inflated by junk.

I created a configuration file called “ref-spam.conf” in the conf-enabled directory.

The content of that file looks like this:

RewriteEngine On
RewriteCond %{HTTP_REFERER} aio\.online [NC]
RewriteRule .* - [F,L]

I ended up on this “solution” because any time I messed with the configuration file for maerk.xyz specifically, Apache would fail to start.

If any Apache wizards could help me out, I’d appreciate it.

First question: after adding that config file, did you restart Apache (httpd)?

Yep. Didn’t get any errors upon restarting.

What happens when you run sudo a2enmod rewrite?

“Module rewrite already enabled”

You can try this variant:

RewriteEngine On
# Ensure we are looking for the domain anywhere in the referrer string
RewriteCond %{HTTP_REFERER} ^https?://([^/]+\.)?aio\.online [NC]
RewriteRule ^ - [F,L]

Also, if you are loading your site via a VirtualHost, you will need something like this in your VirtualHost block:

RewriteOptions Inherit
1 Like