利用Apache手工屏蔽各种广告(无聊人士玩玩)

1.在hosts文件里对需要屏蔽广告的网站加上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 hm.baidu.com
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. 设置apache转发,这里直接用默认路径改

<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的页面都转发到?adimage.html

3.配置一下转发到的页面

<html>
    <body>
        <!--<image src="/adimage/psb.jpg">-->
        <?php echo "我卖广告我傻逼,哦也!"; ?>
    </body>
<html>

 4.效果图

原文地址:https://www.cnblogs.com/zemliu/p/2571586.html