doudi4621 2011-09-22 09:22 采纳率: 0%
浏览 102
已采纳

.htaccess文件影响包含文件(包括图像)

I'm currently trying to use a script that ensures users are logged into a central sign-on system.

The problem is that any files, including PHP and image files, in this sub-folder are not accessible when included, whether simply when using <?php include 'file.php' ?>, just as an image, i.e. <img src="image.png" />, etc.

The code that I am using in the .htaccess file is below:

RewriteEngine on
# The original URL is set as an environment variable SSO_REQUESTED rather than
# a query parameter, so it's not vulnerable to hacking.
# It shows up in PHP as $_SERVER['REWRITE_SSO_REQUESTED'].
RewriteCond %{REQUEST_URI} !ssoclient
RewriteRule (.+) /sso/ssoclientfilter.php [E=SSO_REQUESTED:$1,L]

Any help here would be greatly appreciated.

  • 写回答

2条回答 默认 最新

  • dongsu1539 2011-09-22 09:44
    关注

    If the point of your code is to make sure that your users are logged into a central sign-in system wouldn't the PHP code:

    <?php
    
    if (!isset ($_COOKIE[ini_get('session.name')])) {
         session_start();
    }else{
         print "<SCRIPT>window.location='/sso/ssoclientfilter.php';</SCRIPT>";
    }
    

    In the above code, anyone without a session previously started gets directed to your ssoclientfilter.php and your other images and folders aren't touched. This placed where your session_start() is located should cover your issue.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!