文章页Adsense广告放置和.htaccess防盗链重定向技巧

在网站上放置Adsense广告可以获得一些收入补贴一部分域名和主机上的金钱投入,那么怎么放置这些Adsense广告在文章页喃?一般的WordPress主题可以打开theme目录下的“single.php”,找到” < ?php the_content(); ?> ”所在的地方。

1. 在WordPress日志内容顶部加Adsense广告:

在”< ?php the_content(); ?>”上面加上广告代码即可,示例:

<div style=”padding:0px 10px″>
Google Adsense Code
</div>
<?php the_content(); ?>

2.在WordPress日志内容底部加Adsense广告:

同上,但广告代码要加在“ < ?php the_content(); ?> ”下面,示例:

<?php the_content(); >
<div style=”padding:0px 10px″>
Google Adsense Code
</div>


3.在WordPress日志左侧(右侧)加Adsense广告:

<div style=”float:left(right); padding:0px 10px″>
Google Adsense Code
</div>
<?php the_content(); ?>

4.让二个Adsense广告并排显示:

<table align=center><tr><td><table border=”0″ align=”left”><tr><td>Google Adsense Code1</td></tr></table></td><td><table border=”0″ align=”left”><tr><td>Google Adsense Code2</td></tr></table></td></tr></table>

或者

<table align=center><tr><td>Google Adsense Code1</td><td>Google Adsense Code2</td></tr></table>

防止图片盗链,可以有效节约网站的流量。那么WordPress怎么进行防盗链设置喃?假设你的图片存放目录为 image,就在该目录下放置 .htaccess 文件,比如喜报的图片目录在wp-content/uploads下,就在该目录下放置了一个 .htaccess 文件,内容如下:

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !xibao.org [NC]
RewriteCond %{HTTP_REFERER} !google.cn [NC]
RewriteCond %{HTTP_REFERER} !google.com [NC]
RewriteCond %{HTTP_REFERER} !google.com.tw [NC]
RewriteCond %{HTTP_REFERER} !google.com.sg [NC]
RewriteCond %{HTTP_REFERER} !google.com.hk [NC]
RewriteCond %{HTTP_REFERER} !google.com.my [NC]
RewriteCond %{HTTP_REFERER} !google.co.jp [NC]
RewriteCond %{HTTP_REFERER} !soso.com [NC]
RewriteCond %{HTTP_REFERER} !mail.qq.com [NC]
RewriteCond %{HTTP_REFERER} !image.baidu.com [NC]
RewriteCond %{HTTP_REFERER} !feedsky.com [NC]
RewriteCond %{HTTP_REFERER} !bing.com [NC]
RewriteCond %{HTTP_REFERER} !sogou.com [NC]
RewriteCond %{HTTP_REFERER} !image.soso.com [NC]
RewriteCond %{HTTP_REFERER} !baidu.com [NC]
RewriteCond %{HTTP_REFERER} !zhuaxia.com [NC]
RewriteCond %{HTTP_REFERER} !xianguo.com [NC]
RewriteCond %{HTTP_REFERER} !feedburner.com [NC]
RewriteCond %{HTTP_REFERER} !yahoo.com [NC]

RewriteRule .(jpg|gif|png|bmp|jpeg) http://www.xibao.org/thumb/no.jpg [R,NC,L]

这段代码的意义是先判断是否存在盗链,如果属于盗链行为,即访问图片的请求不是直接输入网址,也不是来自 于xibao.org,google.cn,google.com ……或 yahoo.com,就让所有盗链喜报wp-content/uploads目录下图片的网页,所引用图片(类型为jpg|gif|png|bmp|jpeg)用地址为http://www.xibao.org/thumb/no.jpg的图片替换。替换图片最好在其他没有设置防盗链的目录下,比如喜报的thumb/目录。

当网站更换域名时,从搜索引擎优化角度来看,301 重定向是域名重定向的最佳选择。当网站域名变更后,搜索引擎只对新网址进行索引,同时又把原地址链接全部搬移到新的域名下,保证域名更换不影响收录和排名。 编辑根目录的 .htaccess 文件,加入如下内容:

Options+FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old-example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old-example.com [NC]
RewriteRule ^(.*)$ http://www.xibao.org/$1 [L,R=301]

这段代码就实现了301转向,将old-example.com和www.old-example.com的流量全部重定向到了www.xibao.org。

Related Posts

  1. Google Adsense广告在喜报上停止投放
  2. 在Thematic页首右侧加入Adsense广告代码
  3. 喜报8月更新日志
  4. 喜报11月更新日志
  5. Header横幅广告在不同分辨率下的错位问题
  6. 喜报投放Adsense广告第一个月总结
  7. 将Thematic的站名改为图片logo显示
  8. 茅台成2012年央视广告招标新标王
This entry was posted in 就是不分類 and tagged , , , , , , , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

无觅相关文章插件,快速提升流量