Blank Adsense ads on certain pages

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;
rewrite ^/(.*) 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:
http://forum.nginx.org/read.php?2,217145,217145#msg-217145

On 24 Out 2011 01h03 WEST, [email protected] wrote:

others do not. Certain forums show ads, other ads do not. Certain
RewriteBase /


##redirect to www
server {
server_name twinkinfo.com;
rewrite ^/(.*) http://www.twinkinfo.com/$1 permanent;
}

Like this:

server {
server_name twinkinfo.com;
return 301 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.

http://nginx.org/en/docs/debugging_log.html

— appa

On 24 Out 2011 01h39 WEST, [email protected] 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;
return 301 http://www.twinkinfo.com;
}

Oops. $request_uri is missing:

server {
server_name twinkinfo.com;
return 301 http://www.twinkinfo.com$request_uri;
}

— appa

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs