Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple files in htaccess files tag

Tags:

.htaccess

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>
like image 754
Alqin Avatar asked Apr 12 '12 11:04

Alqin


People also ask

Can you have multiple .htaccess files?

You can have more than one . htaccess file on your hosting account, but each directory or folder can only have one. For example, you can have separate . htaccess files in your root folder and another in a sub-folder.

What is FilesMatch in Apache?

FilesMatch allows you to match files using a regular expression. On your above FilesMatch you have 4 sets of regular expression where the 1 set have an secondary optional set. Basically what it is doing is forbidden access (error 403) to any of the files found that are described on your sets of regex.

What should htaccess file contain?

htaccess file can be used to load customized error pages (such as 404 pages), create URL redirects, implement password-protected authentication for specific directories on your server, and more.

What does htaccess command do?

. htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.


1 Answers

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$">
like image 66
Vytautas Avatar answered Sep 28 '22 04:09

Vytautas