怎样利用你的闲置域名展示Google Adsense广告
不知道大家在访问一些尚未启用的域名时有没有遇到过下面这样的广告页面:

有没有想过将自己的闲置域名也设计成类似的广告页?做一个网页然后插入Google Adsense的代码?其实完全不用这么麻烦,原来Google Adsense已经提供了很便利的方法,只需要修改自己域名的DNS设置就可以。实际上,你并不需要一个完全闲置不用的域名,只要www子域名是空闲没有使用的。比如说,你可以将blog.example.com做为你的blog网址,而把暂不需要使用的www.example.com指向广告。以下是具体的方法:
1. 在Google Adsense控制面板中选择"New hosted domain", 添加你的域名
2. 按以下其中一种方法修改DNS设置:
2a). 把域名的nameserver指向Google的DNS nameserver:
* ns1.googleghs.com
* ns2.googleghs.com
* ns3.googleghs.com
* ns4.googleghs.com
或者,如果你希望更精确的控制使用子域名,那么可以:
2b). 修改别名(CNAME)和A记录如下:
修改CNAME (此处pub-xxxxxxxxx指你的Adsense帐号的唯一ID):
| Host Name/Alias | Record Type | Value/Destination |
| www | CNAME (alias) | pub-xxxxxxxxx.afd.ghs.google.com |
修改A记录:
| Host Name/Alias | Record Type | Value/Destination |
| @ | A (address) | 216.239.32.21 |
| @ | A (address) | 216.239.34.21 |
| @ | A (address) | 216.239.36.21 |
| @ | A (address) | 216.239.38.21 |
只需要按照A或B方法中的一种修改域名配置,然后等待一段时间生效(大约几小时),你的域名就会被自动指向Google的广告页。另外,这个页面所展示广告的样式、语言等等都可以登录Adsense账户修改。这个是我用自己的域名产生的结果:www.xuyuan.me 感兴趣的同学可以自己动手试试看。
Updated 2011.02.04: 发现pub-xxxxxxxxx.afd.ghs.google.com也属被墙之列,为了让网页能在墙内正常访问,可以自己使用Nginx做一个反向代理,配置如下:
upstream adghs {
server pub-xxxxxxxxx.afd.ghs.google.com;
}
server {
listen 80;
server_name www.xuyuan.me;
access_log /var/log/nginx/ghs.xuyuan.me.log;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_pass http://adghs;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect false;
}
}
这样 www.xuyuan.me 的网页应该可以在墙内正常打开了。(题外话:至于运行Nginx的Server,可以利用Amazon的免费EC2服务,具体细节下文再述。)
原来是这么一个东西呀,就是想空手套白狼唄。