Getting the actual URL in browser when

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • news@celticbear.com

    Getting the actual URL in browser when

    I'm trying to mask a URL and found a great way to point one domain to
    another while keeping the original domain name in the browser address
    bar:

    <VirtualHost *:80>
    DocumentRoot /var/www/html/demodomain
    ServerName demodomain.com
    ServerAlias www.demodomain.com
    RewriteEngine on
    RewriteRule /(.*) http://www.actualdomai n.com/$1 [P]
    </VirtualHost>

    But I need to be able to determine if the bowser address is
    "actualdomain.c om" or "demodomain.com ".
    I've tried to get it with these:

    $host = $_SERVER['HTTP_HOST'];
    $uri = $_SERVER['PHP_SELF'];
    $servername = $_SERVER['SERVER_NAME'];
    $httphost = $_SERVER['HTTP_HOST'];
    $httpref = $_SERVER['HTTP_REFERER'];
    $remotehost = $_SERVER['REMOTE_HOST'];
    $requri = $_SERVER['REQUEST_URI'];

    But $_SERVER['HTTP_REFERER'] is the only one that will show one or the
    other correctly, however, ONLY after the person clicks on an href on
    the page. The initial page they go to that variable will be unset.

    Is there any way to determine which domain name is in the browser
    address bar from the start?
    Thanks!!
    Liam

  • Jerry Stuckle

    #2
    Re: Getting the actual URL in browser when

    news@celticbear .com wrote:[color=blue]
    > I'm trying to mask a URL and found a great way to point one domain to
    > another while keeping the original domain name in the browser address
    > bar:
    >
    > <VirtualHost *:80>
    > DocumentRoot /var/www/html/demodomain
    > ServerName demodomain.com
    > ServerAlias www.demodomain.com
    > RewriteEngine on
    > RewriteRule /(.*) http://www.actualdomai n.com/$1 [P]
    > </VirtualHost>
    >
    > But I need to be able to determine if the bowser address is
    > "actualdomain.c om" or "demodomain.com ".
    > I've tried to get it with these:
    >
    > $host = $_SERVER['HTTP_HOST'];
    > $uri = $_SERVER['PHP_SELF'];
    > $servername = $_SERVER['SERVER_NAME'];
    > $httphost = $_SERVER['HTTP_HOST'];
    > $httpref = $_SERVER['HTTP_REFERER'];
    > $remotehost = $_SERVER['REMOTE_HOST'];
    > $requri = $_SERVER['REQUEST_URI'];
    >
    > But $_SERVER['HTTP_REFERER'] is the only one that will show one or the
    > other correctly, however, ONLY after the person clicks on an href on
    > the page. The initial page they go to that variable will be unset.
    >
    > Is there any way to determine which domain name is in the browser
    > address bar from the start?
    > Thanks!!
    > Liam
    >[/color]

    Why go to all that trouble? Just create an alias entry for the other domain.
    No rewriting necessary.

    Or, if you want different options, create another virtual host for the other
    domain and point it at the same directory.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Rik

      #3
      Re: Getting the actual URL in browser when

      Jerry Stuckle wrote:[color=blue]
      > Or, if you want different options, create another virtual host for
      > the other domain and point it at the same directory.[/color]

      Which would give you a great oppertunity to use $_SERVER['SERVER_NAME']

      'SERVER_NAME'

      The name of the server host under which the current script is executing. If
      the script is running on a virtual host, this will be the value defined for
      that virtual host.

      Grtz,
      --
      Rik Wasmus


      Comment

      • news@celticbear.com

        #4
        Re: Getting the actual URL in browser when


        Jerry Stuckle wrote:[color=blue]
        > news@celticbear .com wrote:[color=green]
        > > I'm trying to mask a URL and found a great way to point one domain to
        > > another while keeping the original domain name in the browser address
        > > bar:
        > >
        > > <VirtualHost *:80>
        > > DocumentRoot /var/www/html/demodomain
        > > ServerName demodomain.com
        > > ServerAlias www.demodomain.com
        > > RewriteEngine on
        > > RewriteRule /(.*) http://www.actualdomai n.com/$1 [P]
        > > </VirtualHost>
        > >
        > > But I need to be able to determine if the bowser address is
        > > "actualdomain.c om" or "demodomain.com ".
        > > I've tried to get it with these:
        > >
        > > $host = $_SERVER['HTTP_HOST'];
        > > $uri = $_SERVER['PHP_SELF'];
        > > $servername = $_SERVER['SERVER_NAME'];
        > > $httphost = $_SERVER['HTTP_HOST'];
        > > $httpref = $_SERVER['HTTP_REFERER'];
        > > $remotehost = $_SERVER['REMOTE_HOST'];
        > > $requri = $_SERVER['REQUEST_URI'];
        > >
        > > But $_SERVER['HTTP_REFERER'] is the only one that will show one or the
        > > other correctly, however, ONLY after the person clicks on an href on
        > > the page. The initial page they go to that variable will be unset.
        > >
        > > Is there any way to determine which domain name is in the browser
        > > address bar from the start?
        > > Thanks!!
        > > Liam
        > >[/color]
        >
        > Why go to all that trouble? Just create an alias entry for the other domain.
        > No rewriting necessary.
        >[/color]
        Oh, my gawd. *thumps self in head* I can't believe I didn't think of
        that.
        Man! I suck!
        Thanks for the clue-by-four. =/
        -Liam
        [color=blue]
        > Or, if you want different options, create another virtual host for the other
        > domain and point it at the same directory.
        >[/color]

        Comment

        • Jerry Stuckle

          #5
          Re: Getting the actual URL in browser when

          news@celticbear .com wrote:[color=blue]
          > Jerry Stuckle wrote:[color=green]
          >>
          >>Why go to all that trouble? Just create an alias entry for the other domain.
          >>No rewriting necessary.
          >>[/color]
          >
          > Oh, my gawd. *thumps self in head* I can't believe I didn't think of
          > that.
          > Man! I suck!
          > Thanks for the clue-by-four. =/
          > -Liam
          >
          >[color=green]
          >>Or, if you want different options, create another virtual host for the other
          >>domain and point it at the same directory.
          >>[/color]
          >
          >[/color]

          Sometimes the obvious is *too* obvious? :-)

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          Working...