2014-01-15 25 views
0

我想只允许我的局域网IP地址访问网站目录和文件保存在具有公共IP的Web服务器上我的局域网电脑正在使用ISP公网IP地址连接,所以我的问题是如何只允许我的局域网ip &哪些ip我需要添加在htacces文件中。 下面是我的.htaccess示例,所以请添加需要的更改。如何配置内网.htaccess文件

<IfModule mod_rewrite.c> 

RewriteEngine On 

# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading 
# slashes. 
# If your page resides at 
# then use 
# RewriteBase /mypage/test1/ 

RewriteBase /SITE_FOLDER 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 
<IfModule !mod_rewrite.c> 
# If we don't have mod_rewrite installed, all 404's 
# can be sent to index.php, and everything works as normal. 
# Submitted by: ElliotHaughin 

ErrorDocument 404 /index.php 

</IfModule> 

而且老兄有在侧面网站文件夹,我应该然后删除或保留他们,因为他们是空白的一些其他.htacess文件???

回答

0

你应该可以在你的.htaccess文件中使用这样的代码。

Order Deny,Allow 
Deny from all 
Allow from 192.168.0.1/24 

当然要用你的局域网IP地址和子网来代替。例如,使用192.168.0.1/24将允许PC的IP范围从192.168.0.1 - 192.168.0.254。您需要使用的IP是内部IP而非您的公众。通常像192.168.0.110.0.0.1