Looie
01-31-2008, 08:23 PM
Can I block several files with .htaccess, or do I have to do it like this?
<files file1.jpg>
order allow,deny
deny from all
</files>
<files file2.jpg>
order allow,deny
deny from all
</files>
I tried Google, but all I can find is how to block either one file, every file in the directory, or multiple extensions.
Thanks
bigfan
01-31-2008, 09:06 PM
I don't think you can put more than one file name in that directive, but you can use wildcards. If the file are named, or you can rename them, in such a way as to use a regular expression, you can use <FilesMatch> (see here (http://httpd.apache.org/docs/2.0/mod/core.html#filesmatch)).
why not keep them all in a seperate directory and simply deny the entire directory?
or use regex... you can block all jpg files? or maybe only the ones starting with file?
<Files ~ "\.(jpg)$">
that might work, im ****ing aweful at regex. look up regex if the above doesnt work, or if you need to moify it.
Looie
02-01-2008, 04:56 PM
I don't think you can put more than one file name in that directive, but you can use wildcards. If the file are named, or you can rename them, in such a way as to use a regular expression, you can use <FilesMatch> (see here (http://httpd.apache.org/docs/2.0/mod/core.html#filesmatch)).
why not keep them all in a seperate directory and simply deny the entire directory?
or use regex... you can block all jpg files? or maybe only the ones starting with file?
<Files ~ "\.(jpg)$">that might work, im ****ing aweful at regex. look up regex if the above doesnt work, or if you need to moify it.
Thanks to both of you for answering, I think I might use the same directory idea.
bigfan
02-01-2008, 09:19 PM
or use regex... you can block all jpg files? or maybe only the ones starting with file?
Code:
<Files ~ "\.(jpg)$">Why I suggested using <FilesMatch> if using regular expressions can be found at my previous link (here (http://httpd.apache.org/docs/2.0/mod/core.html#files)).Extended regular expressions can also be used...<FilesMatch> is preferred, however.Following a software producer's preferences is usually not a bad idea.I might use the same directory idea.That's even better. Or, if possible, you could put them outside the web path altogether and not have to mess with .htaccess.