Real Easy PHP/Java Query

Watch
I have a site, eg www.house.com

I want one ad to show on every single page, except any page that has www.house.com/forum* in the URL.

For the pages that have www.house.com/forum* in the URL I want to show another ad.

I guess either javascript or PHP could do this.

eg.

Define URL

IF URL=www.house.com/forum*

Then

Display AD2

ELSE

Display AD1

I know how it should work, just not the actual code.

Help much appreciated!!!!

PS: Any questions about what I have said please ask, I really need this help :)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Matt, you could try something like that in PHP.

PHP:
<? if (eregi('www.house.com/forum', $_SERVER['HTTP_HOST'].'/'.$_SERVER['PHP_SELF'])) { ?>
Display AD2
<? } else { ?>
Display AD1
<? } ?>
Use HTML code for display Ad2 and Ad1.

Hope that works since I didn't test ;)
 
0
•••
Hey man, thanks for that, but it only shows the AD1 (also shows AD1 where AD2 should be displayed)

I cant get it to show AD2
 
0
•••
Oops, sorry, did a little mistake ;)

PHP:
<? if (eregi('www.house.com/forum', $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'])) { ?>
pub 1	
<? } else { ?>
pub 2
<? } ?>
I tested and it works...

Next time, I test before to post code ;)
 
0
•••
Thanks so much - works perfectly!!!
 
0
•••
Any idea how to change the PHP version of this code, to include multiple URLs?

ie. abc.com/a.php and abc.com/b.php it doesnt display

But for any other abc.com address it will display?

Cheers
 
0
•••
Try something like :
Code:
<?if (eregi('www.abc.com/a.php|www.abc.com/b.php', $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'])) { ?> 
pub 1     
<? } else { ?> 
pub 2 
<? } ?>
 
0
•••
PHP:
<?php
$urls[] = 'www.house.com/forum';
$urls[] = 'www.house.com/a.php';
$urls[] = 'www.house.com/b.php';
// etc...
if (eregi($urls, $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])) { ?> 
pub 1     
<?php } else { ?> 
pub 2 
<?php } ?>
 
0
•••
Cheers all

I am trying to setup GoogleAds in my VB forums, but you cant have it on search results etc, so I am trying to get a script to stop it appearing on those pages.

VB keeps rejecting the code though.
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back