在config.php配置文件中
$baseUrl = str_replace('\\','/',dirname($_SERVER['SCRIPT_NAME']));
$baseUrl = trim($baseUrl,'/');
$config['base_url'] = empty($baseUrl) ? '/' : 'http://'.$_SERVER['SERVER_NAME']."/$baseUrl/";
define("BASE_URL", $config['base_url']);
我的模板页:
<base href="<?php echo BASE_URL; ?>" />
<link rel="stylesheet" type="text/css" href="static/style.css" />
<script language="javascript" type="text/javascript" src="static/jquery.js"></script>
<script language="javascript" type="text/javascript" src="static/xheditor.js"></script>