Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    92
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Getting current Page URL when domain is masked.

    I need to get the domain of a page, but I am using domain forwarding with masking. I'm new to this but here's my explanation.

    I have abc.com pointing to xyz.com/abc/. So when you visit abc.com, abc.com stays in the address but its referencing file at xyz.com/abc/.

    I have tried both these options to get the domain name. The domain I want is abc.com, but it only shows xyz.com. Any ideas?

    PHP Code:
        function curPageURL() {
         
    $pageURL 'http';
         if (
    $_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
         
    $pageURL .= "://";
         if (
    $_SERVER["SERVER_PORT"] != "80") {
          
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
         } else {
          
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
         }
         return 
    $pageURL;
        } 
    PHP Code:
        $domain $_SERVER['HTTP_HOST'];
        echo 
    $domain
    THANKS!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,526
    Thanks
    8
    Thanked 1,091 Times in 1,082 Posts
    This sounds like an .htaccess rewrite rule.

    I'm not an .htaccess expert, but search for it on Google.
    Or maybe someone will pipe-in with a good answer for you.

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    92
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thanks, you think i should have an .htaccess file on abc.com or xyz.com?

  • #4
    New Coder
    Join Date
    May 2009
    Posts
    92
    Thanks
    2
    Thanked 0 Times in 0 Posts
    any ideas? or is this really not possible?

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,526
    Thanks
    8
    Thanked 1,091 Times in 1,082 Posts
    I was waiting for someone else to answer that ... someone that knows .htaccess
    If nobody responds, look around on Google for other forums.

  • #6
    Regular Coder
    Join Date
    Apr 2009
    Location
    somewhere over the rainbow
    Posts
    105
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Simply, it shows xyz.com because:
    'HTTP_HOST' - shows the frame url
    "SERVER_NAME" - shows the file's server name

    so if the file is on xyz.com, "SERVER_NAME" it will show xyz.com.
    if you will execute "SERVER_NAME" on abc.com it will show abc.com, but you cannot print nothing to the browser.

    how did you used the mask???
    there are many ways to keep the abc.com in xyz.com like the querystring and more..
    :. -= | Eran | =- .:
    __________________

  • #7
    New Coder
    Join Date
    May 2009
    Posts
    92
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Eran,

    Thanks for your response.

    I setup the mask by just turning on Forwarding with Masking in the domain manager on goDaddy.

    Any other ideas?

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    No, the only other option I can think of is HTTP_REFERER which is unreliable. The problem here is that PHP doesn't realize its being accessed through a redirect, it only cares about itself.
    On the other hand, the _SERVER superglobal is dependent on the service, protocols and client. That being said, try a simple print_r($GLOBALS); and take a look if there is anything of value in the env or server superglobals that could point back to the abc.com. Try to avoid the HTTP_REFERER unless its you're only option.

    Edit:
    I should mention this as well. Overall this is a security feature. This is to help prevent phishing problems since a redirected script will tell you what it really is and generally will refuse to build links back to you're site. Its a pain if you control both ends, but if you do you can rebuild you're get/post handling to tell it where to link back to. If you don't own the other side, chances are you're SOL (short of luck ) and will not be getting what you're looking for.
    Last edited by Fou-Lu; 10-12-2009 at 05:06 AM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

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