简体   繁体   English

htaccess拒绝php权限目录

[英]htaccess deny php permissions a directory

I have a subfolder called thepictures which I needed write access to for people who use the website feature to upload a picture. 我有一个名为“图片”的子文件夹,使用网站功能上传图片的人需要对其具有写权限。

I was wondering if there is a way I can put a htaccess file in that folder that would disallow access to html and php files and such but still allow access to gif,jpg,bmp say ? 我想知道是否有一种方法可以将htaccess文件放在该文件夹中,以禁止访问html和php文件等,但仍然允许访问gif,jpg,bmp说?

Any help on this is great... 任何帮助都很棒...

Put to the root .htaccess file : if the request URI begins with /thepictures but does not end with one of the specified extensions(jpeg, png and so on), it will be forboden. 放入根.htaccess文件:如果请求URI以/thepictures开头, /thepictures以指定的扩展名之一(jpeg,png等)结束,则将其禁止。

   RewriteCond %{REQUEST_URI} ^/thepictures[NC]
   RewriteCond %{REQUEST_URI} !\.(jpe?g|png|gif)$ [NC]
   RewriteRule .* - [F,L]

您可以使用此规则来阻止对给定文件夹中的html或php文件的访问:

RewriteRule ^thepictures/.+?\.(php|html?)(/|$) - [F,NC]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM