当浏览器请求一个脚本(由PHP动态生成)时,我得到一个404,但是如果我直接去那里就可以了

i'm generating my javascript in PHP. If i include a script tag like this

<script src="http://www.everythingpuntagorda.com/blog?ai1ec_render_js=common_backend&amp;is_backend=true&amp;is_calendar_page&amp;ver=1.11.1-pro" type="text/javascript"></script>

the browser return a 404

enter image description here

but if you go to http://www.everythingpuntagorda.com/blog?ai1ec_render_js=common_backend&is_backend=true&is_calendar_page&ver=1.11.1-pro

you'll see that the javascript is created as expected. This is our .htaccess

DirectoryIndex index.php

#BEGIN HG BLOCK 
#order deny,allow 
#allow from 74.202.255.240/29 
#allow from 216.110.94.176/28 
#allow from 216.110.94.224/27 
#allow from 199.187.122.66 
#allow from 199.187.122.67 
#allow from 78.46.70.238 
#allow from 204.187.12.90 
#allow from 74.86.15.72 
#allow from 180.149.241.242 
#allow from 175.107.133.185 
#allow from 217.27.250.160 
#allow from 174.58.72.114 
#allow from 66.87.109.196 
#deny from all 
#END HG BLOCK

# BEGIN WPSuperCache 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible 
AddDefaultCharset UTF-8 
RewriteCond %{REQUEST_URI} !^.*[^/]$ 
RewriteCond %{REQUEST_URI} !^.*//.*$ 
RewriteCond %{REQUEST_METHOD} !POST 
RewriteCond %{QUERY_STRING} !.*=.* 
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$ 
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC] 
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] 
RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC] 
RewriteCond %{HTTP_user_agent} !^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-).* [NC] 
RewriteCond %{HTTP:Accept-Encoding} gzip 
RewriteCond %{HTTPS} on 
RewriteCond %{DOCUMENT_ROOT}/blog/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz -f 
RewriteRule ^(.*) "/blog/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz" [L]

</IfModule>

# END WPSuperCache

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule>

# END WordPress

This is the function that generates the javascript

/**
 * Render the javascript for the appropriate page
 * 
 */
public function render_js() {
    header( 'Content-Type: application/javascript; charset=utf-8' );
    // Aggressive caching to save future requests from the same client.
    $etag = '"' . md5( __FILE__ . $_GET[self::LOAD_JS_PARAMETER] ) . '"';
    header( 'ETag: ' . $etag );
    $max_age = 31536000;// One Year
    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 ( true === extension_loaded( 'zlib' ) ) {
            ob_start( 'ob_gzhandler' );
            header( 'Content-Encoding: gzip' );
        } else {
            ob_start();
        }

        $js_path = AI1EC_ADMIN_THEME_JS_PATH . DIRECTORY_SEPARATOR;
        $common_js = '';
        $page_to_load = $_GET[self::LOAD_JS_PARAMETER];

        if ( $_GET[self::IS_BACKEND_PARAMETER] === self::TRUE_PARAM ) {
            $common_js = file_get_contents( $js_path . 'pages/common_backend.js' );
        } else if( $page_to_load === self::EVENT_PAGE_JS ||
            $page_to_load === self::CALENDAR_PAGE_JS || 
            $page_to_load === self::LOAD_ONLY_FRONTEND_SCRIPTS ) {
            if ( $page_to_load === self::LOAD_ONLY_FRONTEND_SCRIPTS &&
                true === self::$frontend_scripts_loaded ) {
                return;
            }
            if ( false === self::$frontend_scripts_loaded ) {
                $common_js = file_get_contents( $js_path . 'pages/common_frontend.js' );
                self::$frontend_scripts_loaded = true;
            }

        }
        // create the config object for require js
        $require_config = $this->create_require_js_config_object();
        // load require
        $require = file_get_contents( $js_path . 'require.js' );

        // get jquery
        $jquery = $this->get_jquery_version_based_on_browser( 
            $_SERVER['HTTP_USER_AGENT']
        );
        // load the script for the page

        $page_js = '';
        if ( $page_to_load !== self::LOAD_ONLY_BACKEND_SCRIPTS &&
             $page_to_load !== self::LOAD_ONLY_FRONTEND_SCRIPTS
        ) {
            $page_js = file_get_contents( $js_path . 'pages/' . $page_to_load );
        }


        $translation = $this->get_frontend_translation_data();
        $permalink = get_permalink( $this->settings->calendar_page_id );

        $translation['calendar_url'] = $permalink;

        $tranlsation_module = $this->create_require_js_module( 
            self::FRONTEND_CONFIG_MODULE, 
            $translation 
        );
        $config = $this->create_require_js_module(
            'ai1ec_config',
            $this->get_translation_data()
        );
        echo $require . $require_config . $tranlsation_module . 
                $config . $jquery . $page_js . $common_js;
        ob_end_flush();
    } else {
        // Not modified!
        status_header( 304 );
    }
    // We're done!
    ai1ec_stop( 0 );
}

i had our sysadmin look at this with no effect

查看全部
doujieju0397
doujieju0397
2013/07/03 13:24
  • apache
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复