Forum Moderators: coopster

Message Too Old, No Replies

can i put some php files in /var/www/ in a directory other than html?

         

shams

12:57 am on Oct 21, 2006 (gmt 0)

10+ Year Member



hi,
i setup a local sever, the sever pages are in the /var/www/html/ and when i start the server, it opens the /var/www/html/index.html that is ok, now my question, there is some php files can i put them in a deferent directory then html in the /var/www/ for example /var/www/any_name, and then how i can open them with my server?

barns101

7:26 am on Oct 21, 2006 (gmt 0)

10+ Year Member



If your web root is /var/www/html/ you cannot put any files in directories above this (e.g. /var/www/any_other/) and call them from a web browser. However, you could place files in a directory above the web root and include [php.net] them in files within the web root.

henry0

11:41 am on Oct 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using this in any file from root to any depth dir and files allows you to link from anywhere to a file at root level (here conn_other_dir.php)

require_once($_SERVER['DOCUMENT_ROOT']."/conn_other_dir.php");

then conn_other_dir (located at root level) could be simply an include
for example:
<? //named conn_other_dir.php

require_once("/var/www/any_dir_below_root/file_I_need_to_link_to.php");

?>

A very good way to put it to work is to use that system to hide all DB connect and other admin config files