I'm aware of first line, it's obvious, and for second line I think it's only allowing those few extensions, and third line I assume forbids any other filetype.

I'm not sure if my assumptions are correct, and if given htaccess file is forbidding upload of unwanted other filetypes like php or zip, or exe...

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !(\.jpg|\.jpeg|\.pdf|\.png)
RewriteRule ^(.*)$ - [F]

closed as unclear what you're asking by kasperd, mdpc, peterh, quadruplebucky, Esa Jokinen Jun 14 '17 at 10:09

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • You assumption is correct but code isn't entirely correct - it will allow files like file.jpg.php as it is missing $ at the end of regexp. – AlexD May 23 '17 at 18:06
  • Can you change it and add as answer? I will correct my question. – Aleksandar Pavić May 23 '17 at 18:36
  • 3
    These directives do not forbid the "upload" of anything. It blocks certain URLs being requested (ie. downloaded). – MrWhite May 23 '17 at 19:17
  • @user82217 you are correct, I missed the word 'upload' – AlexD May 23 '17 at 19:48
  • 1
    @user82217 actually question was edited and word upload was added after my comment. – AlexD May 23 '17 at 19:50

This snippet attempts to prohibit access (download) to any files with extensions other than .jpg, .jpeg, .png, .pdf but as it is missing $ at the end it allows access to files with these patterns anywhere in the filename, like file.jpg.php.

  • So proper snippet would be RewriteCond %{REQUEST_FILENAME} !(\.jpg|\.jpeg|\.pdf|\.png)$ ? – Aleksandar Pavić May 24 '17 at 8:05
  • @AleksandarPavić yes – AlexD May 24 '17 at 8:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.