homepage Welcome to WebmasterWorld Guest from 54.237.134.62
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
DOCUMENT ROOT on Local Server Using XAMPP
jamesMP




msg:4604090
 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]

 

JD_Toims




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

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.

lucy24




msg:4604776
 8:12 am on Aug 25, 2013 (gmt 0)

:: 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved