返回首页 我的新博客

在 Nginx 中配置 Zend Framework

1
2
3
4
5
6
7
location / {
    root   d:/public_html;
    index  index.php index.html index.htm;
    if (!-e $request_filename) {
        rewrite ^/(.*)$ /myproject/public/index.php last;
    }
}

按照配置文件,我的项目地址是:http://localhost/myproject/public,项目是部署在子目录 /myproject/public 里面的,如果你把 document_root 直接设置为 /myproject/public,使用 http://localhost 来访问,那么上述配置删除掉 index.php 前面的目录部分,也就是 rewrite ^/(.*)$ index.php last;

Nginx 不支持 Apache 的 .htaccess 文件,所以需要在 Nginx 配置文件中编写重写规则。Apache 的绝大部分 RewriteRule 命令都可以不做修改的放到 Nginx 中直接使用。你只要把 RewriteRule 改成 rewrite,[L] 改成 last 之类的就可以了,具体可以看一下 Nginx 的 Rewrite 文档。

http://wiki.nginx.org/NginxHttpRewriteModule

题外话,Zend Framework 越来越强大,越来越复杂了,很多追求“简洁”的 Coder 们都已经开始信誓旦旦的说要放弃 ZF 。有点搞笑,这就好像我在说:飞机太快了,价钱太贵了,不适合我,还是自行车好啊!有些人对待问题的看法极端又片面,就好像看电视剧的时候,也总是要把人分为好人和坏人一样,他们的想法很单纯——我不喜欢 ZF,因为臃肿、复杂,所以它是垃圾。

posted @ 2011-07-24 21:16  buffer的blogs  阅读(579)  评论(0编辑  收藏  举报