Welcome to WebmasterWorld Guest from 23.23.46.20

Forum Moderators: Ocean10000 & incrediBILL & phranque

DOCUMENT ROOT on Local Server Using XAMPP

   
11:08 am on Aug 22, 2013 (gmt 0)



How do I add a trailing slash to my htdocs folder (C:\xampp\htdocs)?

On my live production site I can include files like:

include($_SERVER["DOCUMENT_ROOT"].'foo/foo.php');


which works fine, but on localhost the server looks for:

C:/xampp/htdocsfoo/foo.php


I've edited the local httpd.conf file (added the trailing slash to DocumentRoot "C:/xampp/htdocs/" and <Directory "C:/xampp/htdocs/">) and tried some rewrite rules (even if I could get my head round regex, would this work anyway?) in htaccess without success.

This only affects files referenced using DOCUMENT_ROOT.

Thanks.

[edited by: phranque at 10:06 pm (utc) on Aug 27, 2013]
[edit reason] disabled graphic smileys [/edit]

5:27 am on Aug 25, 2013 (gmt 0)

WebmasterWorld Senior Member Top Contributors Of The Month



include($_SERVER["DOCUMENT_ROOT"].'foo/foo.php');

That's interesting -- I've given up on "local servers" and only use production servers, but I have include($_SERVER["DOCUMENT_ROOT"].'/foo/foo.php'); on all of them, which I believe is how it should be [or at least it's been that way on every production box I can remember] and makes sense technically according to the docs.

DOCUMENT_ROOT should be:

The document root directory under which the current script is executing, as defined in the server's configuration file.

[php.net...]

Technically /the-path/to-the-file/ is the path of the defined index file of the directory, not the path of the root directory the current file is running under.
8:12 am on Aug 25, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



:: detour to check my own files ::

include($_SERVER["DOCUMENT_ROOT"].'foo/foo.php');


Huh. Mine all say

include ($_SERVER['DOCUMENT_ROOT'] . "/foo/foo.php");


with leading slash. Works identically on MAMP and live server.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month