Alqin
Alqin

Reputation: 1305

Multiple files in htaccess files tag

How I add multiple files in htaccess files tag? The code bellow works for one file.

<Files wp-login.php>
Order Deny,Allow
Allow from 191.211.9.1
Deny from all
</Files>

I end up using this:

<filesMatch "^(wp-login|wp-file)\.php$">
Order Deny,Allow
Allow from 190.190.0.1
Deny from all
</filesMatch>

Upvotes: 12

Views: 13479

Answers (2)

Ruvee
Ruvee

Reputation: 9097

2023 Solution

Here are some options to do so:

Returning "Forbidden" to the user:

In this case, "user"/"hacker"/"adversary"/"pentester" would figure out those files exist on your server but s/he doesn't have access to them!

<FilesMatch "(?:readme|license|changelog|-config|-sample)\.(?:php|md|txt|html?)">
      Require all denied
</FilesMatch>

Returning "404" to the user:

In this case, "user"/"hacker"/"adversary"/"pentester", theoretically, would assume those files don't even exist on your server!

<FilesMatch "(?:readme|license|changelog|-config|-sample)\.(?:php|md|txt|html?)">
      Redirect 404
</FilesMatch>

Upvotes: 2

Vytautas
Vytautas

Reputation: 3539

Try something like this(not tested but should work):

<Files ~ "^(admin|wp-login|one-more-file)\.php$">

or this:

<FilesMatch "^(admin|wp-login|one-more-file)\.php$">

Upvotes: 14

Related Questions