Log in

View Full Version : If URL show this title?



queerfm
11-12-2007, 09:08 AM
Hi i have 3 domain names i would like it that when a users visits lets say www.123.com they get 123 in the title, when they visit www.abc.com they get abc in the title. and so on. Is this possible and how? i tryed

<?
if url == "www.123.com" then print "hello";
?>

However it did not work

killerchutney
11-12-2007, 05:28 PM
Ok, not 100% sure if this will work, but im 99% ;)

The below code needs to be in the place of your title:

<title>


<?php
function getpage() {
$this_page = $_SERVER['PHP_SELF'];
return $this_page;}
if(ereg("page name 1", getpage())) {
echo ('page title 1');}

elseif(ereg("page name 2", getpage())) {
echo ('page title 2');}

elseif(ereg("page name 3", $this_page)) {
echo ('page title 3');}
//you can add more by continuing the trend above
else{ echo ('page title if no matches were found'); }
?>

</title>


hope this has helped.

Twey
11-12-2007, 05:40 PM
Hmm...
<title>
<?php echo preg_replace('/(?:www\.)?([^\.]+)\..*/', '\1', $_SERVER['HTTP_HOST']); ?>
</title>I think that's what you meant?

killerchutney
11-12-2007, 05:43 PM
could be, but from this
if url == "www.123.com" then print "hello";
i thought it needs to be changable - not just the URL minus the www. and the .com and stuff.

Twey
11-12-2007, 06:36 PM
Could well be. Either way, there's code :)