如果注销,htaccess拒绝访问目录(用php检查) [英] htaccess deny acces to directory if logged out (checked with php)
问题描述
如果访问者未登录,我想拒绝其访问。
并将他们重定向到您尚未登录 .html文件。
我该怎么做?
您无法使用Apache来编辑.htaccess。 p>
一种实现此目的的方法是,通过重写规则将每个请求转发到php脚本,并通过此PHP脚本提供文件。
但这很重,如果文件很大,这不是一个好的解决方案。
也许您应该将 Apache dbd auth mod (如果您在数据库中有用户)。但是,这又不是Apache的工作,因为它不擅长。
I would like to deny access to visitors to a specific directory if they are not logged in. And redirect them to a "you are not logged in" .html file.
How can I do this? Is there some way to edit .htaccess with php if logged out?
You can't do this with Apache.
One way to achieve this would be to forward every requests to a php script via a rewrite rule and to serve files via this PHP script.
But this is heavy, if your files are big, this is not a good solution.
Maybe you should look as the Apache dbd auth mod (if you have your users in a database). But again, this should not be the job of Apache because it's not good at it.
这篇关于如果注销,htaccess拒绝访问目录(用php检查)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!