#nginx.conf
location /wx
{
root /wx/public/index.php;
if (!-e $request_filename) {
rewrite ^/wx/(.*)$ /wx/public/index.php?$1 last;
}
}
//public/index.php
<?php
define('BASE_URL', 'http://localhost/wx/');
define("APP_PATH", realpath(dirname(__FILE__) . '/../'));
$app = new Yaf_Application(APP_PATH . "/conf/application.ini");
$app->bootstrap()->run();
#conf/application.ini
[product]
application.directory=APP_PATH "/application/"
application.dispatcher.catchException = TRUE
application.dispatcher.throwException = TRUE
application.modules=index,admin
application.view.ext = 'php'
为什么这样配置,访问http://localhost/wx
会提示
Page was not found
Failed opening controller script /home/wwwroot/default/wx/application/controllers/Wx.php: No such file or directory
#0 /home/wwwroot/default/wx/public/index.php(7): Yaf_Application->run()
#1 {main}
在public/index.php
打印$_REQUEST
,是个空数组
目录结构:bootstrap.php在zapplication下,入口文件index.php在public下
补充一下,把域名绑定到/home/wwwroot/default/wx,用域名是可以访问的(rewrite规则要对应修改,不是上面那个),rewrite规则改成上面那个,再使用http://ip/wx访问(wx是yaf项目目录),就不行了。会把/wx/当成控制器
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…