所以我有一个CSS文件style.css.在同一目录中,我有images /文件夹.
如何制作一个从另一个文件夹压缩style.css的脚本?
现在我有这个:
<?PHP if(isset($_GET['css'])) $file = array('url' => htmlspecialchars($_GET['css']),'type' => 'text/css'); if(isset($_GET['js'])) $file = array('url' => htmlspecialchars($_GET['js']),'type' => 'application/javascript'); if(!isset($file)) exit(); header('Content-type: '.$file['type']); header('Cache-Control: max-age='.(60*60*6).',must-revalidate'); // whitespace+comment removal,in case gzip is off function compress($buffer){ global $file; $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!','',$buffer); $buffer = str_replace(array("\r\n","\r","\n","\t",' ',' ',' '),' ',$buffer); return $buffer; } if(extension_loaded('zlib')) if(substr_count($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip')) ob_start("ob_gzhandler"); else ob_start("compress"); include($file['url']); ob_end_flush(); ?>
@H_404_11@并使用像这样的东西:
<style type="text/css"> @import "http://mysite.com/lib/c.PHP?css=../style.css"; </style>
@H_404_11@一切正常,只是css文件中图像的路径不再起作用.
我认为这是因为(images / bg.jpg)成为(../images/bg.jpg)
最佳答案