SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How would I test/compare the Address Bar text ?

    Hello All!

    How would I test/compare the Address Bar text so that I can forward the user based on its value? Okay, I know that does not make sense.

    I have a domain that points to a main domain. When the user arrives at the main domain the address bar actually reads the original domain name. I would like to point the original domain to a sub directory inside of the main domain but my provider told me they cannot do that.

    So I thought I could test that text and redirect based upon the info.

    Domain 1 -------> main domain/domain1
    Domain 2 -------> main domain/domain2
    Domain 3 -------> main domain/domain3
    Thank you for your time!
    Marc

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    location.href contains the url of the page, so do some if statements on it.
    ck :: bringing chris to the masses.

  3. #3
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Anarchos
    location.href contains the url of the page, so do some if statements on it.
    Sounds great but I am new to this and I am not sure how you code the location.href part.

    Also, does location.href return the address bar or the real location?
    Thank you for your time!
    Marc

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2001
    Location
    North Carolina
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use this code:

    PHP Code:

    $hn 
    strtolower(getenv("HTTP_HOST"));

    switch(
    $hn)
    {
       case 
    "firstdomain.com":
       case 
    "www.firstdomain.com":
          
    $hostname "First Domain";
          include(
    "../texts/firstdomain.txt");
          break;

       case 
    "seconddomain.com":
       case 
    "www.seconddomain.com":
          
    $hostname "Second Domain";
          include(
    "../texts/seconddomain.txt");
          break;

       default:
          
    $hostname "Unknown - Where Are you?";
          include(
    "../texts/index.txt");


    Andrew Thompson
    VPHost.com, part of the Untapped Resources Network.

  5. #5
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP... hmmm, never used it before. I will try it out.

    What is the advantage of PHP versus Javascript?
    Thank you for your time!
    Marc

  6. #6
    SitePoint Zealot
    Join Date
    Aug 2001
    Location
    North Carolina
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm... javascript versus PHP

    I would say that one plus is the PHP code is processed before it ever gets to the user.

    Note: The way I wrote that code "../texts/domain.txt" the texts directory is on the same level as your www dir, not in the www dir. (This is to keep people from poking around in it.)
    Andrew Thompson
    VPHost.com, part of the Untapped Resources Network.


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
  •