Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2007
    Posts
    905

    htaccess question

    Can I block several files with .htaccess, or do I have to do it like this?

    Code:
    <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

  2. #2
    Join Date
    Nov 2005
    Posts
    123
    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).

  3. #3
    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?

    Code:
    <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.

  4. #4
    Join Date
    Aug 2007
    Posts
    905
    Quote Originally Posted by bigfan View Post
    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).
    Quote Originally Posted by Geof View Post
    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?

    Code:
    <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.

  5. #5
    Join Date
    Nov 2005
    Posts
    123
    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).
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •