Get the absolute webroot URL.


/ Published in: PHP
Save to your folder(s)

Get the absolute webroot URL.


Copy this code and paste it in your HTML
  1. if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { define("PROTOCOL", "https://");} // DEFINE PROTOCOL
  2. else { define("PROTOCOL", "http://"); }
  3. define("WEBROOT_URL", PROTOCOL.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])); // DEFINE WEBROOT PATH

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.