# Blank Adsense ads on certain pages

**URL:** <https://www.ruby-forum.com/t/blank-adsense-ads-on-certain-pages/213101>\
**Category:** NGINX\
**Created:** [October 24, 2011, 2:04am UTC](https://www.ruby-forum.com/t/blank-adsense-ads-on-certain-pages/213101 "2011-10-24T02:04:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [October 24, 2011, 2:04am UTC](https://www.ruby-forum.com/t/blank-adsense-ads-on-certain-pages/213101/1 "2011-10-24T02:04:05Z")

</div>

I have inserted my adsense code into my site in certain areas, and the  
issue is very strange: ads only randomly work on some pages, and others  
the ad block still ‘loads’, but nothing appears. Just a black box.

When you load the homepage page, you see the ad…but clicking on the  
forums tab takes you to another page with the **exact same ad code** ,  
but nothing loads. You can even rightclick where the ad should be and  
you can see the iframe it inserted. If you go to the forums and navigate  
the member list, random profiles show ads, others do not. Certain forums  
show ads, other ads do not. Certain forum topics show ads, other don’t.  
Refreshing the page does not help. This stays consistent across multiple  
browsers.

The forum has a “SEO” function available, which I have enabled so the  
URLs look better. The .htaccess file if I had gone with apache is  
structured as follows:

Options -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST\_FILENAME} !-f RewriteCond %{REQUEST\_FILENAME} !-d RewriteRule . /index.php [L]

Turning the SEO URL function to ‘off’ removes the issue of ads not  
appearing, but this isn’t acceptable for us. It just makes me think I  
have done something wrong in the NGINX config file.

Here is the site-available file I have done for this website:

* * *

##redirect to www  
server {  
server\_name [twinkinfo.com](http://twinkinfo.com);  
rewrite ^/(.\*) [1. Mature Buddy Finder – Ideal Connection Website to possess Swingers and you may Threesomes - www.twinkinfo.com](http://www.twinkinfo.com/$1) permanent;  
}  
##################

server {

```
    server_name www.twinkinfo.com;
     root /home/username/www;

    location / {
            index index.php;
            try_files $uri $uri/ /index.php;
    }

    location ^~ /page {

           #?q=$uri&$args; required for in-line JS editor
            try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    ##This is the catch-all for .php files

    location ~ \.php$ {
            include fastcgi_params;
            include fastcgi_config;
            fastcgi_param SCRIPT_FILENAME

```

$document\_root$fastcgi\_script\_name;  
try\_files $uri =404;  
}

## Disable viewing .htaccess & .htpassword

```
    location ~ /\.ht {
            deny all;
    }

```

}

upstream backend {  
server 127.0.0.1:9000;  
}

* * *

I’ve been messing with this for days and can’t seem to figure out a  
reason behind it. If anyone can offer suggestions I would be most  
grateful.

Posted at Nginx Forum:

> **[Blank Adsense ads on certain pages](https://forum.nginx.org/read.php?2,217145,217145#msg-217145)**
>
> I have inserted my adsense code into my site in certain areas, and the issue is very strange: ads only randomly work on some pages, and others the ad block still 'loads', but nothing appears. Just a black box. When you load the homepage page, you see...

---

<div class="post-metadata">

**Author:** ![Skolde](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba9def/32.png) [@Skolde](https://www.ruby-forum.com/u/Skolde)\
**Post date:** [October 24, 2011, 2:40am UTC](https://www.ruby-forum.com/t/blank-adsense-ads-on-certain-pages/213101/2 "2011-10-24T02:40:29Z")

</div>

On 24 Out 2011 01h03 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> others do not. Certain forums show ads, other ads do not. Certain  
> RewriteBase /
> 
> * * *
> 
> ##redirect to www  
> server {  
> server\_name [twinkinfo.com](http://twinkinfo.com);  
> rewrite ^/(.\*) [http://www.twinkinfo.com/$1](http://www.twinkinfo.com/$1) permanent;  
> }

Like this:

server {  
server\_name [twinkinfo.com](http://twinkinfo.com);  
return 301 [http://www.twinkinfo.com](http://www.twinkinfo.com);  
}

> }  
> The catch all location is falling back to index.php without any  
> arguments. Is that the way it’s supposed to be?

> location ^~ /page {
> 
> #?q=$uri&$args; required for in-line JS editor  
> try\_files $uri $uri/ /index.php?q=$uri&$args;  
> }

The URIs starting with page have a fallback to index.php with args.

> ##This is the catch-all for .php files
> 
> location ~ .php$ {  
> include fastcgi\_params;  
> include fastcgi\_config;  
> fastcgi\_param SCRIPT\_FILENAME  
> $document\_root$fastcgi\_script\_name;  
> try\_files $uri =404;  
> }

Is index.php your PHP “handler”? If it is then use this:

location = /index.php {  
include fastcgi\_params;  
include fastcgi\_config;  
fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;  
}

> }  
> Enable the debug log and trace the way the request is handled.

> **[A debugging log](http://nginx.org/en/docs/debugging_log.html)**

— appa

---

<div class="post-metadata">

**Author:** ![Skolde](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba9def/32.png) [@Skolde](https://www.ruby-forum.com/u/Skolde)\
**Post date:** [October 25, 2011, 2:12am UTC](https://www.ruby-forum.com/t/blank-adsense-ads-on-certain-pages/213101/3 "2011-10-25T02:12:59Z")

</div>

On 24 Out 2011 01h39 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > should be and you can see the iframe it inserted. If you go to the  
> > Options -MultiViews
> 
> Like this:
> 
> server {  
> server\_name [twinkinfo.com](http://twinkinfo.com);  
> return 301 [http://www.twinkinfo.com](http://www.twinkinfo.com);  
> }

Oops. $request\_uri is missing:

server {  
server\_name [twinkinfo.com](http://twinkinfo.com);  
return 301 http://www.twinkinfo.com$request\_uri;  
}

— appa

---

<div class="post-metadata">

**Author:** ![Skolde](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba9def/32.png) [@Skolde](https://www.ruby-forum.com/u/Skolde)\
**Post date:** [October 25, 2011, 2:29am UTC](https://www.ruby-forum.com/t/blank-adsense-ads-on-certain-pages/213101/4 "2011-10-25T02:29:37Z")

</div>

> The catch all location is falling back to index.php without any  
> arguments. Is that the way it’s supposed to be?

Yes, adding arguments causes a redirect loop for some reason.

> The URIs starting with page have a fallback to index.php with args.

Those pages use in-line javascript editing which requires args to be  
appended to index.php. Unlike the earlier catch all location, this does  
not cause a redirecting issue.

> Is index.php your PHP “handler”? If it is then use this:

> location = /index.php {  
> include fastcgi\_params;  
> include fastcgi\_config;  
> fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;  
> }

I tried that, but the site no longer loaded any styling and was just  
giant text and white background.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,217145,217258#msg-217258](http://forum.nginx.org/read.php?2,217145,217258#msg-217258)
