Jump to content

Help on php server root and doc root


Recommended Posts

Dear guys,


I have a code that I always use on hosts and it works but is not working now


The code is:


The file is functions.php



// setting up the web root and server root for
// this application
$thisFile = str_replace('\\', '/', __FILE__);

$webRoot  = str_replace(array($docRoot, 'functions.php'), '', $thisFile);
$srvRoot  = str_replace('functions.php', '', $thisFile); 

define('WEB_ROOT', $webRoot);
define('SRV_ROOT', $srvRoot);


All the web files are in the root folder lifeforea


and the admin files are in the lifeforea folder ir lifeforeastafrica/admin


However, when I try to access www.lifeforeastafrica/admin to login into the admoin area, I get the folloeing error:


Not Found


The requested URL /mnt/local/admin/login.php was not found on this server.


Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


Someone help on how I should set my doc and server roots please.....



Link to comment
Share on other sites

Your server is most likely configured incorrectly, meaning that $_SERVER['DOCUMENT_ROOT'] is not returning the correct value. I've only ever personally seen this happen on shared hosting and I believe is not normally using Apache as a httpd. The exactly solution to fix it will very much depend on the server software in use, but the chances are if you are not running a VPS/Dedicated Server, then you will not have the access required for fix these options.

Link to comment
Share on other sites

You shouldn't really need the server root?


$_SERVER['DOCUMENT_ROOT'] will always return the full path to your web root.


Why do you need to use the server root as you call it? - i'll be more than happy to help :)

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.