Jump to content

opening files using absolute path from document root uses root of filesystem


rupurt

Recommended Posts

i am running apache with php5 installed as an apache module. when i try to access files (to open or include etc...) it tries to get the file from the root of the file system rather than the root of the virtual host.

 

here is an example. I am running virtual host test.heg2.com. I want to check if the index.php file exists

 

if(file_exists("/index.php"))

  print "file exists";

else

  print "file does not exist";

 

this never finds the file. However if i put index.php in the root of the file system it finds the file. I have tried setting the doc_root in the apache httpd.conf file and it does set the doc_root to the path of the virtual host but this makes no difference.

 

Is it possible to reference / as the root of the web directory rather than the root of the filesystem?

 

What can i do to solve this problem?

Your in fact telling it to look in root, if you want to check in the current directory use:

 

if(file_exists('./index.php'))
...

OR

 

if(file_exists('index.php))
...

 

The post-'/' means root directory - so infact it SHOULD be showing the root of the filesystem. Most filesystem (NTFS, EXT) conventions state this behavoir shouldn't be changed.

Archived

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.