Page 1 of 1

Problem with $_SERVER['DOCUMENT_ROOT'] in FF

Posted: Sat Mar 13, 2010 9:18 pm
by michaeru
I have these:
PHP File

Code: Select all

 
 
<link type="text/css" rel="stylesheet" href="<?php echo $_SERVER['DOCUMENT_ROOT'] . '/folder/globalStyles.css' ?>" />
 
 
The above code as shown on the Firefox View Source:

Code: Select all

 
 
<link type="text/css" rel="stylesheet" href="C:/xampp/htdocs/folder/globalStyles.css" />
 
 
It does not use my CSS and if I click or go to the href of the link tag, Firefox displays this error:

Firefox doesn't know how to open this address, because the protocol (c) isn't associated with any program.

Another is this:

Code: Select all

 
 
header('Location: ' . $_SERVER['DOCUMENT_ROOT'] . '/folder/page.php');
 
 
It also does not redirect to the page.

Help resolve this.

Re: Problem with $_SERVER['DOCUMENT_ROOT'] in FF

Posted: Sat Mar 13, 2010 11:13 pm
by Christopher
You don't want to use $_SERVER['DOCUMENT_ROOT'] for URLs because it contains the filesystem path. Use $_SERVER[’SCRIPT_NAME’] or 'http://' . $_SERVER[’SERVER_NAME’] . $_SERVER[’SCRIPT_NAME’] instead. This is not a "Firefox problem."

Re: Problem with $_SERVER['DOCUMENT_ROOT'] in FF

Posted: Sun Mar 14, 2010 4:28 am
by michaeru
Oh, will try it out. Thanks.