View Full Version : Getting current Page URL when domain is masked.

10-09-2009, 09:58 PM
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?

function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
} else {
return $pageURL;

$domain = $_SERVER['HTTP_HOST'];
echo $domain;


10-09-2009, 11:14 PM
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.

10-09-2009, 11:25 PM
thanks, you think i should have an .htaccess file on abc.com or xyz.com?

10-10-2009, 06:06 PM
any ideas? or is this really not possible?

10-10-2009, 06:32 PM
I was waiting for someone else to answer that ... someone that knows .htaccess
If nobody responds, look around on Google for other forums.

10-10-2009, 09:49 PM
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..

10-12-2009, 04:50 AM

Thanks for your response.

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

Any other ideas?

10-12-2009, 05:03 AM
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.

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.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum