This is my first question on StackExchange so bear with me, here is a brief breakdown of my current setup:
- Two different domains, two different TLDs (.dk and .de) on the same hosting plan
- for the sake of privacy, let's assume the domain names are "example website", i.e.
https://www.example.dkandhttps://www.example.de - SSL set up on both domains
- WordPress-driven, using WPML to serve the translated content accordingly
The problem is, I'm getting a crazy amount of hits (from countries like China, India, and Pakistan) for /not_found at the end of both domain names' URLs, in all possible formats:
- secure, along with the www protocol (
https://www.example....../not_found) - secure, without the www protocol (
https://example....../not_found) - non-secure, along with the www protocol (
http://www.example....../not_found) - non-secure, without the www protocol (
http://eksemp....../not_found)
To me, this peculiar pattern looks most likely to be nothing more than vulnerability scan attempts, especially taking into account that the content on the sites is written in either Danish or German. Moreover, the websites are addressing to a specific Danish, or German target group, thus making it very unlikely for the websites to be worth a visit to the visitors from those Asian countries. Currently, the server's response is the 404-not found page provided by the WordPress theme that we're using, which in my opinion is not ideal because I would rather have them be denied access to that URL, even if it doesn't actually exist.
Long story cut short, I've been struggling over the past couple of days to figure out how to forcibly make the web server output the 403-forbidden page instead of the 404 one since the specified URL does not exist on the server.
I created a regular expression which I aim to use in the .htaccess file as a pattern that covers all the above-mentioned scenarios (4 for each domain name). The part of code that I placed in .htaccess goes as follows
# BEGIN /not_found blocking
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(https{0,1}:\/\/)(www\.){0,1}(example\.dk|example\.de){1}(\/not_found){1}$
RewriteRule . - [R=403,NC]
</IfModule>
# END /not_found blocking
but alas it doesn't work, as I'm still getting the 404-not found error page instead of 403 Access Forbidden. It must be my fault, but what's the reason?
Any help would be greatly appreciated. Thanks a lot!