Hi,
I have just upgraded to WAMP 2.0 and which has caused error to ALL my sites.
I have some code which determines the web root, and I use this to reference include files such as CSS, javascript etc as well as images.
Here is the code:
// setting up the web root and server root for
// this shopping cart application
$thisFile = str_replace('\\', '/', __FILE__);
//define document root
//determine whether running MS IIS or Apache
$server_sw = $_SERVER["SERVER_SOFTWARE"];
if (substr($server_sw, 0, 9) == "Microsoft"){
$docRoot = substr($_SERVER['ORIG_PATH_TRANSLATED'], 0, strlen($_SERVER['SCRIPT_NAME']) * - 1);
$docRoot = str_replace('\\', '/', $docRoot);
} else
{
$docRoot = $_SERVER['DOCUMENT_ROOT'];
}
$webRoot = str_replace(array($docRoot, 'library/config.php'), '', $thisFile);
$srvRoot = str_replace('library/config.php', '', $thisFile);
$web_path = "http://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'];
define('DOC_ROOT', $docRoot);
define('WEB_ROOT', $webRoot);
define('SRV_ROOT', $srvRoot);
define('WEB_PATH', $web_path);
No the problem is WAMP is using the folder name in the reference. e.g.
http://localhost/site_1/images/image.jpg - this is what I want
http://localhost/site_1/site_1/images/image.jpg - this is what I get
I reference files using PHP like so: <?=WEB_ROOT?>images/image.jpg
and WEB_ROOT = "site_1" (as expected)
Can anyone point me in the right direction???
*I have set PHP to allow <?=?>, so that is not the problem
by: elvin66Posted on 2009-11-04 at 20:25:56ID: 25746768
Try formatting your doc root statement like this and see if it works.
oot);
$server_doc_root = $_SERVER['DOCUMENT_ROOT'];
define ("SITE_ROOT",$server_doc_r