jcadima
7/27/2015 - 4:25 PM

Get WEB_ROOT

Get WEB_ROOT

http://stackoverflow.com/questions/2424606/get-webroot-in-php

<?php

$web_root = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/";

OUTPUT -->http://website.com/parent_folder/


//For the directory of the retrieved script, use:
$protocol = $_SERVER['HTTPS'] == '' ? 'http://' : 'https://';
$folder = $protocol . $_SERVER['HTTP_HOST'] . '/' . basename($_SERVER['REQUEST_URI']);


//For your webservers root directory, use:
$protocol = $_SERVER['HTTPS'] == '' ? 'http://' : 'https://';
$folder = $protocol . $_SERVER['HTTP_HOST'];