如果没有在php中设置用户会话,如何使用htaccess文件限制文件访问

时间:2017-05-16 09:13:39

标签: php mysql .htaccess

我遇到以下代码的问题,因为我的代码是htaccess

RewriteEngine On
# you can add whatever extensions you want routed to your php script
RewriteCond %{REQUEST_URI} \.(zip)$ [NC]
RewriteRule ^(.*)$ "pathoffile"/download_file.php [L]

and php code is 

<?php
session_start();
if(!isset($_SESSION))
{
echo "Access Denied";   
}


?>

当我点击以下链接时, 如果会话存在,应该下载文件,但不是。

1 个答案:

答案 0 :(得分:0)

You can redirect all your file requests to a download_file.php?with=filename, then you can validate user section from there.