atwellpub
atwellpub

Reputation: 6010

Get Full URL with PHP & Include Subdomain

I have been using the following to discover the full url, but it does not detect the subdomain I am calling from.

$current_url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]."";
echo $current_url;EXIT;

Any advice?

Upvotes: 1

Views: 1573

Answers (2)

Edd Turtle
Edd Turtle

Reputation: 1531

Tested and works fine for me. Used this code:

<?
$current_url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]."";
echo $current_url;EXIT;
?>

Upvotes: 1

ceejayoz
ceejayoz

Reputation: 180014

$_SERVER['HTTP_HOST'] should include the subdomain. Can you link us to an example page?

Upvotes: 1

Related Questions