比如你的httpd.conf的配置如下:
<virtualHost *:80>
ServerName www.example.com
DocumentRoot "C:/example"
<Directory "C:/example">
AllowOverride all
Order Deny, Allow
</Directory>
</virtualHost>
关键的是需要在example的根目录下面添加一个目录:
.htaccess,这个是用来进行处理所有到该目录下面的请求:
SetEnv DEBUG_ENV TRUE
RewriteEngine On
RewriteCond &{REQUEST_FILENAME} -s [0R]
RewriteCond &{REQUEST_FILENAME} -l [0R]
RewriteCond &{REQUEST_FILENAME} -d
RewriteCond ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
这样在index.php中配置需要的环境,比如:
<?php
// 定义应用程序当前是否为调试模式 defined('DEBUG') || define('DEBUG', (getenv('DEBUG_ENV') == 'TRUE' ? true : false)); // 定义应用程序根目录 defined('PROJECT_PATH') || define('PROJECT_PATH', dirname(dirname(dirname(__FILE__)))); // 定义系统配置文件路径 defined('APPLICATION_CONFIG_INI') || define('APPLICATION_CONFIG_INI', PROJECT_PATH . '/applications/example/config/application.ini'); // 重新定义PHP默认搜索目录 set_include_path(implode(PATH_SEPARATOR, array( PROJECT_PATH . '/library', PROJECT_PATH . '/models', get_include_path() ))); // echo get_include_path();exit; // 调试模式时开启错误输出 if (DEBUG) { error_reporting(E_ALL); ini_set('display_errors', true); } else { error_reporting(8191); } // 设置时区 date_default_timezone_set('Asia/Shanghai'); // 启动Light类库自动载入功能 require_once 'Light/Loader.php'; Light_Loader::autoLoad(); // 载入配置文件 //require_once 'Hexin/Config/Ini.php'; $appcfg = new Hexin_Config_Ini(APPLICATION_CONFIG_INI, !DEBUG); require_once 'Zend/Registry.php'; Zend_Registry::set('appcfg', $appcfg->read()); // 记录整个响应所消耗的时间 $clock = Light_Debug_Clock::getInstance(); ob_start(); // 路由分发请求 $frontController = Light_Controller_Front::getInstance() ->enableAutoRender() ->setModulePath(PROJECT_PATH . '/applications') ->setRouter(new Light_Router_Rewrite()) ->registerPlugin(new example_Controller_Plugin_Auth()) ->dispatch(); // 输出整个响应所消耗的时间(Head头方式) $clock->storage('Dispatch'); ob_end_flush();