I am trying to user header() to direct to a page above the document root. I’m running XAMPP so I’m trying to call a script above htdocs.
My problem is it gives me the 404 error and can’t find the document.
My question: can you use header() to call a script above the document root or is it better to use an include() to accomplish this?
I was trying to be a good php programmer and keep all the scripts with passwords and database access above the htdocs folder.
Thanks in advance.
No you can’t. Anything above the document root does not have a URL, so therefore it is impossible. You want to use an include in a file below the root.
The reason you put all the password files above the root is so Users can’t access them using a URL. This also means you can’t redirect them there using a URL.