Results 1 to 5 of 5

Thread: If URL show this title?

  1. #1
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default If URL show this title?

    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
    The web in one word.

  2. #2
    Join Date
    Jan 2007
    Location
    Bournemouth, England
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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 Code:
    <?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.

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Hmm...
    Code:
    <title>
      <?php echo preg_replace('/(?:www\.)?([^\.]+)\..*/', '\1', $_SERVER['HTTP_HOST']); ?>
    </title>
    I think that's what you meant?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Jan 2007
    Location
    Bournemouth, England
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    could be, but from this
    Code:
    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.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Could well be. Either way, there's code
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •