Problem with Document Root?

I have moved a site from one server to a new one. On the new server, the web site is not working at all. I believe the problem lies within an include page that has the following in it:

/*global $_root;
$_root=$_SERVER['DOCUMENT_ROOT'];*/
define('_ROOT',$_SERVER['DOCUMENT_ROOT']);
global $html_root_offset;
$html_root_offset="";

Specifically, I think it is the $_server line but I really do not have much knowledge in this area.

Does anyone have any ideas of how this might be causing the site not to work? I have changed nothing since the old server location and all worked just fine there.

define ‘not working at all’. White screen? Error messages? Can you access any of the content?

Well I can access the index.php page ok. It is built on a CMS system (a quite old one) which we will be moving into a newer one shortly. Anyways, the links on the page are all driven from within the cms system. When I select a page, I get a 404 - Page not Found.

Okay, 404s. Probably means that your server’s configuration file doesnt list it correctly. Have you checked there?

That’s where I am lost - I really have no knowledge on that end, looking for some guidance. I have access to the server, it is dedicated.

A system 404? Or a CMS generated 404?

What do the links look like in the main page?

Does the CMS have parameters you can set? Like ‘site root’ or things like that?

System 404. Unfortunately I cannot gain access to anything web side within the cms most likely due to that _server setting. At least that is what I am thinking is causing the issue.

Did you bring the .htaccess file(s) over from the old server?

There was no .htaccess file.

You say you can access the index.php, and select pages. I assume ‘select a page’ means clicking a link? What does that link look like?

And even if you can’t access anything on the new site (from the front end), surely you can check the admin part for settings on the old site? Or check the scripts for a config.php or something?

Yes, on the link part.

Unfortunately, this system does not have settings like that in the backend available to change. Everything is within lib files. I have done a search looking for where that variable is set but there is none.

From what I have read through google. sometimes $_server settings are not available on certain servers but I have also read these can be changed. I just do not know where to change it on the server to allow $_server to have function.

throw up a phpinfo(); and check the path it lists as DOCUMENT_ROOT. Is that set correctly? (I’m guessing not.)

No, it is - listed as: DOCUMENT_ROOT /home/mydomain/public_html

and your files are being kept in another directory.

So… just FSAG… replace


define('_ROOT',$_SERVER['DOCUMENT_ROOT']);

with


define('_ROOT','/path/to/my/files');

with the appropriate substitution.

Ok, I changed it to:

/*global $_root;
$_root=$_SERVER['DOCUMENT_ROOT'];*/
define('_ROOT','/home/mydomain/public_html');
global $html_root_offset;
$html_root_offset="";

and I still get a 404. Frustrating.

You… just said that it WASNT in /home/mydomain/public_html … so… why did you put that into the substitution?

Or are you saying that it is in /home/mydomain/public_html… so index.php is located at /home/mydomain/public_html/index.php ?

Yes, it is in: /home/mydomain/public_html… so index.php is located at /home/mydomain/public_html/index.php ?

then DOCUMENT_ROOT should be working correctly… which means you’ve got a problem somewhere else.

Well that is where I go back to the $_Server variable. From the PHP site:

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here.

Well thats simple enough to check. Stick “echo $_SERVER[‘DOCUMENT_ROOT’];” into index.php, and run it. If it spits out the document root, your problem is not in the server variable.