最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

利用Apache服務(wù)器屏蔽廣告及IP段的一般方法

 更新時間:2015年11月27日 14:44:37   作者:Alexis_Liu  
這篇文章主要介紹了利用Apache服務(wù)器屏蔽廣告及IP段的一般方法,同時也介紹了設(shè)置僅允許訪問的IP段從而屏蔽其他一切IP的方法,需要的朋友可以參考下

屏蔽廣告

1.在hosts文件里對需要屏蔽廣告的網(wǎng)站加上host

例如:

#屏蔽百度視屏廣告:
127.0.0.1 a.baidu.com
127.0.0.1 baidutv.baidu.com
127.0.0.1 bar.baidu.com
127.0.0.1 c.baidu.com
127.0.0.1 cjhq.baidu.com
127.0.0.1 cpro.baidu.com
127.0.0.1 drmcmm.baidu.com
127.0.0.1 e.baidu.com
127.0.0.1 eiv.baidu.com
127.0.0.1 hc.baidu.com
127.0.0.1 #
127.0.0.1 ma.baidu.com
127.0.0.1 nsclick.baidu.com
127.0.0.1 spcode.baidu.com
127.0.0.1 tk.baidu.com
127.0.0.1 union.baidu.com
127.0.0.1 ucstat.baidu.com
127.0.0.1 utility.baidu.com
127.0.0.1 utk.baidu.com
127.0.0.1 focusbaiduafp.allyes.com

 

2. 設(shè)置apache轉(zhuǎn)發(fā),這里直接用默認路徑改

<Directory "E:/Apache Software Foundation/Apache2.2/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !(adimage.html)$
RewriteRule ^(.*)$ /adimage.html [L]
</IfModule>
</Directory>

這里會將所有adimage.html的頁面都轉(zhuǎn)發(fā)到?adimage.html

3.配置一下轉(zhuǎn)發(fā)到的頁面

<html>
  <body>
    <!--<image src="/adimage/psb.jpg">-->
    <?php echo "我賣廣告我@#$%^&*,哦也!"; ?>
  </body>
<html>

4.效果圖

20151127144002209.jpg (970×481)

有些時候查看apache日志,會發(fā)現(xiàn)很多莫名其面的IP來訪問網(wǎng)站,
下面介紹一個簡單的屏蔽指定IP或者IP端的方法:
 
 
定位到你的Apache安裝目錄下的conf文件夾,
找到httdp.conf文件,
加入如下內(nèi)容:
 

<Directory "你的網(wǎng)站根目錄">
  Options Indexes FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from 192.168.1.99   
</Directory>

 
解釋如下:
1、
<Directory  "你的網(wǎng)站根目錄">,這里“你的網(wǎng)站根目錄”是在這個httdp.conf文件里,
使用
DocumentRoot "你的網(wǎng)站根目錄" 語句定義的 雙引號 "……" 里的值,比如說/var/www/html之類的。
 
2、AllowOverride None
 
# AllowOverride 這個屬性有兩個值,None和All
當(dāng) AllowOverride 的值為All時,網(wǎng)站根目錄里面的 .htaccess文件才能生效。
至于什么是.htaccess文件,請自己Google。
 
3、
   

Order deny,allow
  Deny from 192.168.1.99 

 
使用這個命令來達到屏蔽IP的作用,類似的用法還有:

# 允許所有主機訪問
  Order deny,allow
  Allow from All 

 

# 禁止所有主機訪問
  Order deny,allow
  Deny from All

 
把上面的All改成指定的IP即可達到屏蔽某個IP的效果。
屏蔽IP端也一樣,比如說屏蔽192.168.1.123這個IP所在的192.168.1這個IP段,只需要這樣寫:

 
# 禁止192.168.1這個IP段訪問
  Order deny,allow
  Deny from 192.168.1.123/24

 
另注:
當(dāng)書寫為:

  Order deny,allow
  Deny from All
  Allow from 192.168.1.100

此時是禁止除了192.168.1.100這個IP之外的所有IP訪問,也就是Deny,Allow這兩個命令,在最后一個命令完成時才確定允許那些IP,禁止哪些IP。
 
請舉一反三:

  Order deny,allow
  Allow from All
  Deny from 192.168.1.100

 
沒錯,這段的意思是 允許除了192.168.1.100之外的所有IP訪問。

相關(guān)文章

最新評論

丁青县| 河源市| 东平县| 永新县| 鞍山市| 简阳市| 交口县| 长海县| 林口县| 安庆市| 宣恩县| 蒙阴县| 乐至县| 蕉岭县| 丽水市| 本溪市| 类乌齐县| 旬邑县| 汾阳市| 金昌市| 四川省| 芜湖县| 黄大仙区| 沧源| 台江县| 务川| 毕节市| 奉新县| 木兰县| 兰州市| 邵阳市| 福清市| 浮梁县| 兴隆县| 北辰区| 长泰县| 黎平县| 张掖市| 罗源县| 高州市| 桓台县|