Martin Pfeffer
Martin Pfeffer

Reputation: 12627

apache: block request via RewriteRule in .htaccess

On my apache server I want to block every request containing the string test.

e.g. https://example.com/test/index.php

This should be blocked via the .htaccess file, since the url contains test.

Can you please help me creating the regex statement?

Upvotes: 1

Views: 633

Answers (1)

anubhava
anubhava

Reputation: 785146

You can just use a simple rule at top of your .htaccess like this:

RewriteEngine On

RewriteCond %{REQUEST_URI} /test/ [NC]
RewriteRule ^ - [F]

Upvotes: 3

Related Questions