Skip to content

Instantly share code, notes, and snippets.

@anggadarkprince
Created October 8, 2018 07:40
Show Gist options
  • Save anggadarkprince/325c7c7081362923104c23ac6995d5a5 to your computer and use it in GitHub Desktop.
Save anggadarkprince/325c7c7081362923104c23ac6995d5a5 to your computer and use it in GitHub Desktop.
Dynamic URL
<?php
if (isset($_SERVER['HTTP_HOST']) && $_SERVER["SCRIPT_NAME"]) {
$root = (isset($_SERVER["HTTPS"]) ? "https://" : "http://") . $_SERVER['HTTP_HOST'];
$root = $root . str_replace(basename($_SERVER["SCRIPT_NAME"]), "", $_SERVER["SCRIPT_NAME"]);
} else {
$root = 'localhost/absent';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment