minify - PHP - Minify :: serve - HTTP / 1.0 400 Bad Request

时间:2011-01-02 16:56:25

标签: php http request minify

我使用此文档 minify

http://code.google.com/p/minify/wiki/CustomServer

我遇到无法解决的问题:

<?php

    set_include_path('/srv/home/xyz/public_html/COMPONENTS/_php/minify/min/lib' . 
                PATH_SEPARATOR . get_include_path());
    require 'Minify.php';
    require 'Minify/Cache/File.php';
    Minify::setCache(new Minify_Cache_File()); 

    //no error - everything is ok... until now

    $options = array(
        'files'  => array('/srv/home/xyz/public_html/test1.js', 
                    '/srv/home/xyz/public_html/test2.js', $src),
        'maxAge' => 86400
    );
    Minify::serve('Files', $options);

    //--> HTTP/1.0 400 Bad Request



?>

我尝试过:

    'files'  => array('test1.js', 'test2.js', $src),
    'files'  => array('//test1.js', '//test2.js', $src),
    'files'  => array('/srv/home/xyz/public_html/test1.js', 
                      '/srv/home/xyz/public_html/test2.js', $src),

我还将这些文件放在不同的位置而没有正面结果。 问题是:发生了什么事?为什么HTTP请求存在?

1 个答案:

答案 0 :(得分:1)

从数组中删除$ src变量:

<?php
$options = array(
    'files'  => array('/srv/home/xyz/public_html/test1.js', 
                '/srv/home/xyz/public_html/test2.js'),
    'maxAge' => 86400
);
?>

array('/srv/home/xyz/public_html/test1.js') // this path is absolute physical path
array('//test1.js') // this path is a relative path from document root of the web-server

HTTP请求存在,因为您应该将脚本的链接插入到html文件中:

<script type="text/javascript" src="/js/script.js.php" ></script>

如果其中一个包含的文件不存在,服务器必须发送404响应(NOT FOUND)