Forum Moderators: coopster
Warning: main(http*//www.site.com/includes/include_name.php): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in /home/***/public_html/category/pagename.htm on line 1
Warning: main(): Failed opening 'http*//www.site.com/includes/include_name.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/***/public_html/category/pagename.htm on line 1
So basically my question is how can I let pages 2+ levels deep access the includes folder in the root directory with absolute links to http*//www.site.com/includes/page_include.php while not letting in visitors to the site? I don't want people to be browsing my includes folder.
Thanks.
Then you should be able to just
include $_SERVER['DOCUMENT_ROOT'] . "/includes/include_name.php";
or you could get your host to turn off the listing dir contents in apache.
I usually reference my include files with an absolute filesystem path, like:
include("/home/directory/includes/included-file.php");
...instead of using an http:// path. And then the directory that the includes are in are not accessible. Meaning, there is no http:// path that points to /home/directory/includes... it is outside of ./public_html.
ini_set('include_path', ini_get('include_path') . ':' . $_SERVER['DOCUMENT_ROOT'] . '/../includes/');
Your include path will end up looking something like this:
.:/usr/local/lib/php:/my/server/web/path/mysite/../includes/
[edited by: coopster at 12:42 am (utc) on June 29, 2005]