简体   繁体   English

.htaccess-拒绝除一个文件夹之外的所有文件夹

[英].htaccess - Deny all except one folder

I am trying to deny all connections to my website using .htaccess that looks something like this: 我试图拒绝使用.htaccess到我的网站的所有连接,如下所示:

ErrorDocument 403 /errors/403\.php

SetEnvIfNoCase Request_URI "^/errors/403\.php$" HANDLE403
order deny,allow
deny from all
allow from 188.167.150.5
allow from 78.145.188.71
allow from env=HANDLE403  

AddType application/x-httpd-php53 .php
AddType application/x-httpd-php5 .php52
AddType application/x-httpd-php .php4

The .htaccess file is stored in the root folder of my ftp and this works fine, however I want to use custom Error 403 page which is saved in Errors folder on the same ftp, so basically it gets blocked too. .htaccess文件存储在我的ftp的根文件夹中,并且工作正常,但是我想使用自定义的Error 403页面,该页面保存在同一ftp的Errors文件夹中,因此基本上也被阻止了。 I have tried to create a new .htaccess in the Errors folder (as suggested in other topics) with this code: 我尝试使用以下代码在Errors文件夹中创建一个新的.htaccess(如其他主题中所建议):

order allow,deny
allow from all

AddType application/x-httpd-php53 .php
AddType application/x-httpd-php5 .php52
AddType application/x-httpd-php .php4

But it still doesn't work and I get just the default 403 page with "Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request." 但是它仍然无法正常工作,我只得到默认的403页面,其中包含“此外,尝试使用ErrorDocument处理请求时遇到了403 Forbidden错误”。

Any idea how I could fix this, so that the error files are accessible by all, while the rest is denied for all except few specific IPs? 知道如何解决此问题,以便所有人都能访问错误文件,而除少数特定IP之外的所有其他IP被拒绝吗?

Use your custom handler like this: 使用您的自定义处理程序,如下所示:

ErrorDocument 403 /errors/403.php

order deny,allow
deny from all
allow from 188.167.150.5
allow from 78.145.188.71

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

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