我的项目使用htaccess文件来限制对服务器资源的访问。通过HTTP身份验证授予访问权限。
我想离开HTTP身份验证,使用类似于php-session的登录身份验证来检查访问。
我想要做的事情可以简单地在一个脚本中完成,比如:
<?php
session_start()
if ( !isset($_SESSION['user']) ) {
header('location : /login.php');
exit;
}
//...also we could use url rewriting to redirect all urls pointing to static resource through
// a script that will deliver its content or redirect to the login form depending on
// identification status在动态页面中使用php不是问题,但是在apache中如何使用与cookie一起传递的会话id来访问静态资源?
我在apache中见过与基于cookie的重定向相关的问题,但没有一个问题涉及到基于cookie传递的sessionId来识别用户。
发布于 2011-04-20 23:29:07
对于HTML内容,将您的“静态”内容保留在PHP脚本中,PHP脚本唯一的“动态”特性是包含一个用于检查登录/会话的公共标头。
对于图片,css,javascript,文档,任何其他东西,this more extensive discussion都会有帮助。
https://stackoverflow.com/questions/5732791
复制相似问题