Jump to: navigation, search

PHP FULL URL

From w3cyberlearnings

Contents

PHP CURRENT Full URL

Get current Full URL.

Example 1

<?php
//www.woowood.com/request.php?ac=33;
echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
?>

Output

www.woowood.com/request.php?ac=33;

Example 2

<?php

$proto = strtolower($_SERVER['SERVER_PROTOCOL']);
$protocol = strpos($proto, 'https')
		  === TRUE ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'];
$script = $_SERVER['SCRIPT_NAME'];
$params = $_SERVER['QUERY_STRING'];

$URL = $protocol . '://' . $host . $script . '?' . $params;

echo $URL;
?>

Related Links

Manage URL
  1. PHP CURRENT URL
  2. PHP CURRENT HOST
  3. PHP URL Parameters
  4. PHP URL PROTOCOL
  5. PHP URL Script Name
  6. PHP FULL URL
  7. PHP URL Parent Directory
Navigation
Web
SQL
MISC
References