Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess deny access to specific files? more than one

Tags:

I am able to disable access to a file with .htaccess, but I don't know how to disallow multiple files to be viewed (directly, not from includes)

They are .php so I can't disable a file type (like the only tutorials online say..)

<FILES ... ?   </FILES> 

Or something.. For example "home.php, file.php , test.php" how do I disallow access to all three files with that tag? or similar, help please!

like image 461
oni-kun Avatar asked Feb 02 '10 09:02

oni-kun


People also ask

What does htaccess Deny from all do?

htaccess to make it happen. For example, deny from all is a command that will allow you to apply access restrictions to your site.

Can I have two 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 .htaccess file and why it is used?

. 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

If you want to exclude files based on regular expressions, you could use FilesMatch instead of Files, e.g.:

<FilesMatch ^((home|test|file)\.php$|mysecretfolder|asecretpicture\.jpe?g)$> ... </FilesMatch> 
like image 151
Residuum Avatar answered Oct 15 '22 14:10

Residuum