2

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 に何を追加すればよいですか?

4

2 に答える 2

1

CSS を表示しようとすると、代わりに "Apache 2 Test Page powered by CentOS" HTML ページが表示されます。ページの応答ヘッダーで「403 Forbidden」が宣言されています。

これはあなたの積極的なキャッシングに関連している可能性がありますか?

PHP で次の行を修正するとどうなりますか。

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

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

?

于 2013-05-21T21:43:48.837 に答える
0

PHPでContent-typeを設定しましたが、サーバーがそのスクリプトに別のContent-typeを強制しているようです。スクリプトに css 拡張子を設定して、mod_rewrite で書き直すことができます。

<link media="all" type="text/css" href="http://tylldalil.wconsult.no/css_1367403986_ver_3.5.1.css" id="ai1ec_stytle-css" rel="stylesheet">

.htaccess:

RewriteEngine On

RewriteCond %{ENV:REDIRECT_FINISH} !^$
RewriteRule .* - [L]

RewriteCond %{REQUEST_FILENAME}  !-f
RewriteRule css_([0-9])+_ver_([0-9.]+)\.css$ ?ai1ec_render_css=$1&ver=$2 [E=FINISH:1,L]

RewriteCond %{HTTP_HOST} ^localhost$
RewriteRule ^(/)?$ ?page_id=23 [R=301,L]
于 2013-05-22T11:36:07.177 に答える