apache httpd + PHP authentication
| From: | news.php.net | Date: | Sat, 18 Oct 2003 21:20:02 +0000 |
| Subject: | apache httpd + PHP authentication | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-166631@lists.php.net to get a copy of this message | ||
Hello,
httpd v1.3.27, php v4.3.0.
I have a web page I wish to restrict access. I prefer to use the standard apache httpd authentication with .htaccess and password file. This method does not seem to work with PHP.
A "parser" is called every time a page is accessed. If no page is defined, the home page is loaded. Subsequent pages are linked with URLs like "http://mysite.com/?page=nextpage.php". In the parser I define a "base_dir" variable that allows access to a common set of code files regardless of where the page file is. The complete parser is:
require('./php/lib/base-dir.inc'); // Assigns $base_dir
$page = $_REQUEST['page'];
if ("" == $page)
$page = "main-index.php";include($base_dir . $page); So the restricted page is in a subdirectory with a .htaccess file to indicate that a name/password is required. This is ignored, presumably because the file is include()'d. I have looked at the authentication info in the docs. I have to do all the work of verifying the name/password. I do not wish to do so since an satisfactory method already exists. Is there a way to use a parser as above and still have httpd recognize the need for a name/password? -- jimoe at sohnen-moe dot com