相关疑难解决方法(0)

使用htaccess进行IP限制

我想以这样的方式限制整个站点,即只有两个IP可以进入该站点.我的.htaccess(站点的根目录)中有以下内容:

ErrorDocument 403 http://www.example.com/views/error403.html

Order Deny,Allow
Deny from all
Allow from 311.311.311 322.322.322.322

ErrorDocument 404 /views/error404.html
ErrorDocument 500 views/error500.html
Run Code Online (Sandbox Code Playgroud)

(显然,这些都是伪造的IP,在我的.htaccess中它们是正确的IP)

正如你所看到的,我只允许322.322.322.322和311.311.311.0/24的所有IP,并拒绝其他人.我想要的是,当任何人从另一个IP进入该网站时,他将查看error403.html页面.

过滤器工作正常,但不是重定向.当我尝试从拒绝IP进入网站时,我看到一条Apache消息:

Found
The document has moved here
Run Code Online (Sandbox Code Playgroud)

其中"here"是error403.html的链接.

我想我甚至限制了error403.html页面.

我该怎么做这个限制,但允许查看错误页面?我应该将error403.html页面移动到另一个目录(即/ views/error /)并将其他.htaccess放入其中,在该文件中允许所有IP吗?

先感谢您!

apache .htaccess restriction

14
推荐指数
1
解决办法
2万
查看次数

限制访问受限用户的PHP脚本

我有一个PHP网站,有多个PHP脚本.我需要从另一个站点向用户提供有限访问权限的用户.我想限制这些ppl可以访问的页面.

我这样做的方式如下:

// $_SESSION['systemid'] is set with a value of say, '1'
$permissionArray = $objACCESS->getPermissions($_SESSION['systemid']);

// getPermissions returns an array like the following (for that systemid):
// 0 => {'systemid' => '1', 'permission_type' => 'createcontent' }
// 1 => {'systemid' => '1', 'permission_type' => 'invitecontacts' }

// the following contain a list of script names that should be 
// restricted if permission is not allowed
$createcontent = array('createcontent.php');
$managecontent = array('managecontent.php');
$invitecontacts = array('invitecontacts.php');

$page_name=basename($_SERVER["SCRIPT_FILENAME"]);

if(is_array($permissionarray))
{
    $haspermissions = false; …
Run Code Online (Sandbox Code Playgroud)

php permissions

5
推荐指数
1
解决办法
1675
查看次数

如何根据IP地址确定国籍?

如何根据客户端IP告诉我的网站用户的国籍?

编辑:赞评论,这个问题之前已经回答过:

/sf/ask/19811151/

globalization ip

0
推荐指数
1
解决办法
2192
查看次数

标签 统计

.htaccess ×1

apache ×1

globalization ×1

ip ×1

permissions ×1

php ×1

restriction ×1