gpt4 book ai didi

php - 资源解释为样式表,但使用 MIME 类型文本/html 和 PHP 中生成的 css 传输

转载 作者:行者123 更新时间:2023-11-28 12:19:19 24 4
gpt4 key购买 nike

我有一个不解释 css 的网站。我看过其他答案,但没有看到动态生成的 css 的答案。我通过添加

在 PHP 中生成 CSS
<link media="all" type="text/css" href="http://tylldalil.wconsult.no/?ai1ec_render_css=1367403986&ver=3.5.1" id="ai1ec_stytle-css" rel="stylesheet">

我在 php 中的函数

public function render_css() {
header( 'Content-Type: text/css' );
// Aggressive caching to save future requests from the same client.
$etag = '"' . md5( __FILE__ . $_GET[self::GET_VARIBALE_NAME] ) . '"';
header( 'ETag: ' . $etag );
$max_age = 31536000;
header(
'Expires: ' .
gmdate(
'D, d M Y H:i:s',
Ai1ec_Time_Utility::current_time() + $max_age
) .
' GMT'
);
header( 'Cache-Control: public, max-age=' . $max_age );
if (
empty( $_SERVER['HTTP_IF_NONE_MATCH'] ) ||
$etag !== stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] )
) {
// compress data if possible
if ( extension_loaded( 'zlib' ) ) {
// ob_start( 'ob_gzhandler' );
}
$content = $this->get_compiled_css();
echo $content;
ob_end_flush();
} else {
// Not modified!
status_header( 304 );
}
// We're done!
exit( 0 );
}

这是我的htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?tlldalil.wconsult.no$
RewriteRule ^(/)?$ ?page_id=23 [R=301,L]

order deny,allow
deny from all
allow from 88.89.104.103
allow from 93.50.99.14



###Start Kloxo PHP config Area
###Please Don't edit these comments or the content in between. kloxo uses this to recognize the lines it writes to the the file. If the above line is corrupted, it may fail to recognize them, leading to multiple lines.

<Ifmodule mod_php4.c>
php_value error_log "/home/klausen/__processed_stats/tylldalil.wconsult.no.phplog"
php_value upload_max_filesize 64M
php_value max_execution_time 60
php_value max_input_time 120
php_value memory_limit 64M
php_value post_max_size 64M
php_flag register_globals off
php_flag display_errors off
php_flag file_uploads on
php_flag log_errors off
php_flag output_buffering off
php_flag register_argc_argv on
php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off
php_flag magic_quotes_sybase off
php_flag mysql.allow_persistent off
php_flag register_long_arrays on
php_flag allow_url_fopen on
php_flag cgi.force_redirect on
php_flag enable_dl on
</Ifmodule>

<Ifmodule mod_php5.c>
php_value error_log "/home/klausen/__processed_stats/tylldalil.wconsult.no.phplog"
php_value upload_max_filesize 64M
php_value max_execution_time 60
php_value max_input_time 120
php_value memory_limit 64M
php_value post_max_size 64M
php_flag register_globals off
php_flag display_errors off
php_flag file_uploads on
php_flag log_errors off
php_flag output_buffering off
php_flag register_argc_argv on
php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off
php_flag magic_quotes_sybase off
php_flag mysql.allow_persistent off
php_flag register_long_arrays on
php_flag allow_url_fopen on
php_flag cgi.force_redirect on
php_flag enable_dl on
</Ifmodule>

###End Kloxo PHP config Area




# BEGIN WordPress

# END WordPress

我应该向我的 htaccess 添加什么?

最佳答案

当我尝试查看您的 CSS 时,我得到的是“由 CentOS 提供支持的 Apache 2 测试页”HTML 页面。页面响应 header 声明“403 Forbidden”。

这可能与您的激进缓存有关吗?

如果在您的 PHP 中修改以下行会发生什么:

$etag = '"' . md5( __FILE__ . $_GET[self::GET_VARIBALE_NAME] ) . '"';

$etag = '"' . md5( __FILE__ . $_GET[self::GET_VARIABLE_NAME] ) . '"';

?

关于php - 资源解释为样式表,但使用 MIME 类型文本/html 和 PHP 中生成的 css 传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16678697/

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