Securing dir

What is the best way to secure a dir that holds some php include files. I am on apache and as such tried .htaccess and so on, the problem is that the parser will not have access either to the files. what to do. Is there a better way.

Basically what i have is a single file with all the db passwords and the link in stored in a dir called secure under my web path and as such is viewable, what i want to do is stop access to this form the out side world, i thought of moving the dir out side the normal web path but hit a problem I use the following code to get a path to the .inc file

 $scriptArea = "http://" . $HTTP_HOST . "/secure";

this will not work if I move the dir.

So what is the best way to do this.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

GibbleConnect With a Mentor Commented:
move the file out of there, put it wherever on the HD, just not in your web directory if you don't want it web accessible, the PHP files should still read it.
windows or unix?
kplonkAuthor Commented:
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Ok I don't know why I asked because it didn't really matter anyhow :p

Just put the files anywhere outside the /htdocs directory and use the path /home/secure/somefile to access them in your php script, it should work fine.
kplonkAuthor Commented:
/home/secure/somefile this path does not seem to work, is that all i need

$scriptArea = "/home/secure/";

is this correct or do i nned to change somthing
You did put the file there right?
kplonkAuthor Commented:
yer, but the real path to my site is


this does not work corectly either do i need some sort ot relitive placer like a ~ or somthing

thanks -k-
kplonkAuthor Commented:
I understand that, the proble i have is how to find the path to it. form any where in the web structure. What i dont know is how to do absolut addresssing in php
kplonkAuthor Commented:
This is the real path
Say the script is running at
"home/sites/site56/web/article/index.php" real path
"" web path

and the code of the script "index.php" is


     include "/home/sites/site56/scripts/index.php";


what am I doing wrong..? thanks
kplonkAuthor Commented:
Thanks for the input on moving the scripts out side of the web folder
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.