gpt4 book ai didi

php - 使用 PHP 静态文件加载器加载 CSS 样式时出现问题

转载 作者:太空宇宙 更新时间:2023-11-04 05:17:21 25 4
gpt4 key购买 nike

我正好有the same problem treated in this topic .那是:我在某些文件夹中有一些静态文件,我希望只有一些用户可以看到该内容。用户来自以前的登录。

为此,我正在尝试实现本主题中给出的第一个解决方案,即:

Create the following .htaccess file under "static-files":

Options +FollowSymLinks  
RewriteEngine on
RewriteRule ^(.*)$ ../authorize.php?file=$1 [NC]

And then in authorize.php...

if (isLoggedInUser()) readfile('static-files/'.$_REQUEST['file']);
else echo 'denied';

This authorize.php file is grossly over simplified, but you get the idea.kquote

因此,将任何请求重定向到 authorize.php 文件,该文件检查用户是否已登录,如果是,则提供内容。

这与 html、js 和图像完美配合……但我不知道为什么不显示 css 样式。这很奇怪,因为我可以直接用我的浏览器访问那个 css 文件,但是当它们从 html 调用时它不起作用。当然,如果我尝试在没有 authorize.php 的情况下工作,样式会照常显示。

我错过了什么?

谢谢,

最佳答案

您可能没有发送正确的 content-type header 。这使得样式表在 Firefox 中失败。

做一个

header("Content-type: text/css");

每当请求 CSS 样式表时。

关于php - 使用 PHP 静态文件加载器加载 CSS 样式时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7558055/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com