I have upload
folder where registered user can upload files. How to block all http requests except .png .jpg .gif to upload
folder and all sub-folders? Other than upload
should not be affected.
It can be done by something like RedirectMatch 404 ^/u/.*\.([^png]+|[^jpg]+|[^jpeg]+|[^gif]+|[^svg]+)$
. This is not very correct regexp, but I can't invert (png|jpg|jpeg|gif|svg)
Please help make correct regexp or use something different than RedirectMatch
Update: I have following rewrite rules, how to make both answer and mine work? Just put answer's rules after RewriteEngine On
? I can't try it and test, as website is not fully functional yet.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,L]
# startreplace
RewriteRule ^Блог.html$ blog.php [E=HumanURL:1,L]
...