Apache/PHP AddHandler 包装器上的 400 错误请求
我正在尝试创建一个包装器/处理程序,每当有人请求目录内的任何 PHP 脚本时,Apache 服务器都会调用该包装器/处理程序。这样我就可以为整个目录授权用户,或者编写一些其他内容,以便在调用目录时调用。
这是我能想到的最佳配置...
<Directory "/srv/http/INNOV/PUBLIC_HTML">
Options -Indexes
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.php
</Directory>
然后在 /srv/http/INNOV/PUBLIC_HTML/kb/ 中我有这个 .htaccess 文件...
Options -Indexes
AddHandler auth_handler .php
Action auth_handler ../auth_handler.php
然后在 /srv/http/INNOV/PUBLIC_HTML/ 中kb/auth_handler.php 如下...
<?php
$FILE = $_SERVER['PATH_TRANSLATED'];
echo $FILE;
?>
访问日志:
- - [02/Dec/2010:17:43:15 -0500] "GET /kb/index.php HTTP/1.1" 400 590
错误日志:
[Thu Dec 02 17:50:19 2010] [error] [client XXX.XXX.XXX.XXX] Invalid URI in request GET /kb/ HTTP/1.1
我检查了我的浏览器,它似乎正在发出正确的请求。
I'm trying to create a wrapper/handler that will be called on the Apache server whenever someone requests any PHP script inside of a directory. That way I can authorize users for the entire directory or write some other stuff to be called when the directory is called.
This is the best configuration I've been able to come up with...
<Directory "/srv/http/INNOV/PUBLIC_HTML">
Options -Indexes
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.php
</Directory>
Then in /srv/http/INNOV/PUBLIC_HTML/kb/ I have this .htaccess file...
Options -Indexes
AddHandler auth_handler .php
Action auth_handler ../auth_handler.php
Then in /srv/http/INNOV/PUBLIC_HTML/kb/auth_handler.php is as follows...
<?php
$FILE = $_SERVER['PATH_TRANSLATED'];
echo $FILE;
?>
Access Log:
- - [02/Dec/2010:17:43:15 -0500] "GET /kb/index.php HTTP/1.1" 400 590
Error Log:
[Thu Dec 02 17:50:19 2010] [error] [client XXX.XXX.XXX.XXX] Invalid URI in request GET /kb/ HTTP/1.1
I've checked my browser and it seems to be making a proper request.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
nvm,我所要做的就是删除 htaccess 文件中的 ../ 。杜尔!抱歉。
nvm, all I had to do was remove the ../ in the htaccess file. DUR! Apologies.