As you can see, the main forum and topic pages on this site display Google Ads. These text-based ads spider the site they're on and display relevant links targeted to the content of the current page. This works perfectly for a page such as

http://www.techtalkforums.com/forums/viewforum.php?f=1 which is the Windows forum, for example.

However, recently to increase search engine placement (as search engines far prefer static pages to dynamic pages) I used mod_rewrite in the .htaccess file to make the .php files appear as if they're static .html files. (Information about mod_rewrite can be found here: http://httpd.apache.org/docs/mod/mod_rewrite.html )

This was done via the following code in the .htaccess file:

RewriteEngine on 
 
# RewriteRule ^f([0-9]+)t([0-9]+)r([0-9]+)s(.*).(.*)$ /forums/viewforum.php?f=$1&topicdays=$2&start=$3&sid=$4 [L]
RewriteRule ^f([0-9]+)t([0-9]+)r([0-9]+).(.*)$ /forums/viewforum.php?f=$1&topicdays=$2&start=$3 [L]
# RewriteRule ^f([0-9]+)r([0-9]+)s(.*).(.*)$ /forums/viewforum.php?f=$1&start=$2&sid=$3 [L]
RewriteRule ^f([0-9]+)r([0-9]+).(.*)$ /forums/viewforum.php?f=$1&start=$2 [L]
# RewriteRule ^f([0-9]+)s(.*).(.*)$ /forums/viewforum.php?f=$1&sid=$2 [L]
RewriteRule ^f([0-9]+).(.*)$ /forums/viewforum.php?f=$1 [L]
 
# RewriteRule ^t([0-9]+)p([0-9]+)(.*)r([0-9]+)s(.*).(.*)$ /forums/viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4&sid=$5 [L]
RewriteRule ^t([0-9]+)p([0-9]+)(.*)r([0-9]+).(.*)$ /forums/viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4 [L]
# RewriteRule ^t([0-9]+)r([0-9]+)s(.*).(.*)$ /forums/viewtopic.php?t=$1&start=$2&sid=$3 [L]
RewriteRule ^t([0-9]+)r([0-9]+).(.*)$ /forums/viewtopic.php?t=$1&start=$2 [L]
# RewriteRule ^t([0-9]+)s(.*).(.*)$ /forums/viewtopic.php?t=$1&sid=$2 [L]
RewriteRule ^t([0-9]+).(.*)$ /forums/viewtopic.php?t=$1 [L]
# RewriteRule ^p([0-9]+)s(.*).(.*)$ /forums/viewtopic.php?p=$1&sid=$2 [L]
RewriteRule ^p([0-9]+).(.*)$ /forums/viewtopic.php?p=$1 [L]
 
# RewriteRule ^c([0-9]+)s(.*).(.*)$ /forums/index.php?c=$1&sid=$2 [L]
RewriteRule ^c([0-9]+).(.*)$ /forums/forums.php?c=$1 [L]
# RewriteRule ^s(.*).(.*)$ /forums/index.php?sid=$1 [L]
RewriteRule ^index.html$ /forums/index.php [L]
RewriteRule ^forums.html$ /forums/forums.php [L]
 
# RewriteRule ^m([0-9]+)s(.*).(.*)$ /forums/profile.php?mode=viewprofile&u=$1&sid=$2 [L]
RewriteRule ^m([0-9]+).(.*)$ /forums/profile.php?mode=viewprofile&u=$1 [L]

The .htaccess file only involves the homepage, board index, forum views, and topic views pages, as these are the only important ones to be indexed by search engines such as google.

What this does, for example, is it creates .html aliases for .php files, in layman terms. For example, you can use http://www.techtalkforums.com/forums/f1.html as a URL. This html file runs the associated .php script http://www.techtalkforums.com/forums/viewforum.php?f=1. Then, it forwards the output of this .php page over to the .html file for displaying.

Now here's the problem. When using the real URLs such as http://www.techtalkforums.com/forums/viewforum.php?f=1 the Google ads displayed are entirely relevant. For example, if you're in the Windows forum, it'll display Microsoft info, Linux forum displays Linux links, etc etc.

However, when using the html aliases, all of the ads displayed on every page are related to general computing. They're the same ads that are usually displayed on the index.php (index.html) and forum.php (forum.html) pages.

It's not like the google ads can't recognize the HTML pages at all, because then the ads wouldn't be relevant at all. But instead, they're relevant but to my index/forum homepages. The only code related to these HTML pages is in the .htaccess file displayed above. Can anyone spot any code in there that might be a reason for this?

I earn money for each click to the Google ads, and I would hate to lose so much money only because relevant ads aren't being displayed when they should.

TIA!

P.S. The reason that some of the lines of the .htaccess file are hashed out (commented out) is because those deal with Site IDs, which I prefer not to incorporate into the URLs on TechTalk Forums, although the default IS to include them on the phpBB forum software (that is used here). Any ideas would be greatly appreciated!

One more thing that might help in solving this dilemma. The two lines which are commented out ...

# RewriteRule ^c([0-9]+)s(.*).(.*)$ /forums/index.php?c=$1&sid=$2 [L]
# RewriteRule ^s(.*).(.*)$ /forums/index.php?sid=$1 [L]

... actually produce a very undesired effect when uncommented. They prevent access to the search.php page! Even though none of the code is related to search.php in any way, trying to access search.php when these lines aren't commented will always redirect you back to the main index page regardless of where you are.

Perhaps if those could redirect you to the index page, then other lines I don't have commented can redirect googlebot (google's spider) to the index page? (and therefore reading the index page's meta tags and content instead of the appropriate page's).

ONCE AGAIN, TIA

I think I might have just hit another milestone in trying to debug this problem. I use an index.cgi file in the root of the /www directory to forward subdomains to particular forums.

For example, each subdomain is a mirror of the entire site. However, http://linux.techtalkforums.com forwards you to http://linux.techtalkforums.com/forums/f3.html (which is the linux forum homepage). From there, you can browse the entire site under the linux subdomain.

Now here's the catch. If you traverse the entire site via www.techtalkforums.com all of the google ads displayed are relevant to all of computing (e.g. content is based on techtalkforums.com/forums/index.html). However, if you traverse the entire site via linux.techtalkforums.com, all of the ads are based on linux. If you traverse the entire site via webdev.techtalkforums.com, you'll see only web development links in google regardless of where in the site you are.

It seems as if the google ads are always pulling from the default homepage instead of the current page. Of course, this doesn't happen when directly accessing .php files. Only when accessing their .html counterparts.

This is so frustrating. I can't decide which is more important! Making money by displaying relevant ads. Or hopefully increasing my search engine popularity via static pages!! :)

This is so frustrating. I can't decide which is more important! Making money by displaying relevant ads. Or hopefully increasing my search engine popularity via static pages!!

Can't both be done?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.