Introduction
If a large number of connections are being made to an invalid or undesired URI, you can block these in Apache by using the Rewrite module. This article discusses how to configure this in either Apache or a user's local .htaccess file.
Procedure
To prevent these connections from tying up the resource of your Apache service, you can use the Rewrite module to deny the requests for matching URIs. By only specifying the URI this can be used to prevent connections to any domains or even the servers IP.
To accomplish this you can use a Rewrite ruleset like the following. Where you would replace Undesired.php with the offending URI path(Example: http://domain.tld/Undesired.php)
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/Undesired.php
RewriteRule ^(.*)$ - [F,L]
To configure this for a specific account or domain, this configuration can be added to the applicable .htaccess file. You can use the cPanel File Manager to make this change. For details on how to use this feature, see the following documentation.
To configure this for all domains on the server, you can add it to the Pre Virtualhost Apache Includes. For details on how to configure this, see the following documentation.
Comments
0 comments
Article is closed for comments.