Connect via FTP to your website, go to the document root, and create, or edit, the file called .htaccess
. Your document root should contain either index.php
or index.html
file. That's how you know it's the document root. If the file exists, edit it. Otherwise, create it.
Now, edit that file, and make sure you have the following content. Some lines may already be there. Add this content at the end. If it already contains RewriteEngine On
- dont touch it and just add the next 2 out of 3 lines below:
RewriteEngine On RewriteCond % ^mail\..*$ [NC] RewriteRule ^.* - [F]
The first line enables the RewriteEngine. The second line specifies that the RewriteRule will work only if the domain starts with mail.
. The final line, takes any request, and sends the 403 - Forbidden
HTTP status message.
This should work fine if the server used is Apache HTTPD
, however if others, like nginX
are used, you'd have to look how to do the same with them. For nginX
, it would be something like this:
if ($host ~* ^mail\..*$ ) { return 444; }
Sending a non-standard, 444 status, causes the connection to close, without sending any response. Alternatively you could send 403 if you want a "Forbidden" status.
Unfortunately I can't vouch for nginX
since I've never used it. Maybe you'd need to write that to a different file or something. I don't know. But you probably have Apache HTTPD there.
Also, this question belongs on either stackoverflow.com, or serverfault.com.