GoogleAdsense的ads.txt未找到的解决方案

前提:

请十分确认ads.txt已经正确配置,即访问如www.liuhe36.cn/ads.txt返回的数据是正确的,如果无法访问到ads.txt,请确认nginx配置。

继续:

在确认ads.txt可以访问,但google还是提示ads.txt找不到时,可能是因为某些特殊字符导致。

请登录服务器,是使用如下命令检查文件的末尾是否存在其他字符。

od -c /var/www/html/ads.txt
0000000   g   o   o   g   l   e   .   c   o   m   ,       p   u   b   -
0000020   4   0   6   0   1   8   8   2   6   7   6   4   2   3   8   5
0000040   ,       D   I   R   E   C   T   ,       f   0   8   c   4   7
0000060   f   e   c   0   9   4   2   f   a   0  \n

注意上边最后一个字符,我的这个文件是多了个\n,想删除掉使用如下命令

1、编辑

vim /var/www/html/ads.txt 

2、在vim中输入

:set binary
:set noendofline
:wq

3、检查是否成功

od -c /var/www/html/ads.txt