国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > php开源 > 综合技术 > Nginx+PHP CGI+QeePHP的rewrite配置

Nginx+PHP CGI+QeePHP的rewrite配置

来源:程序员人生   发布时间:2013-10-27 14:43:10 阅读次数:3647次

  网(LieHuo.Net)教程 Windows下Nginx+PHP CGI+QeePHP好看又好用的rewrite配置

以下为引用的内容:
root   E:/HTML;           
location / {
     index  index.php index.html index.htm
;           
     if (!-f $uri){
               set $rule_0 1$rule_0;
          }
          if (!-d $uri){
               set $rule_0 
2$rule_0;
          }
          #注意顺序,21与12,结果可不一样 代码来自:网,更多:www.wfuwu.com
          if ($rule_0 = "21"){
               #Nginx没有虚拟目录的概念,所以绕开这个问题,加第一组正则匹配。
               rewrite ^/([a-z-A-Z]+)/([a-z-A-Z]+)/([a-z-A-Z]+)/?(.*)$ /$1/index.php?controller=$2&action=$3&$4;
               rewrite ^/([a-z-A-Z]+)/([a-z-A-Z]+)/?$ /$1/index.php?controller=$2 last;
               #这样搞,就可支持X.X.X.X/any_app/controller/action
               #在你的应用程序config的环境文件里,dispatcher_url_mode为rewrite,
               #再使用url("some_controller/some_action"),完美了!
           }
     }

     error_page   500 502 503 504  /50x.html;
     location = /50x.html {
          root   html;
     }

     #一些JS、图片、CSS等静态文件,就不要rewrite了,要不然不正常。开发模式下,把超期设置注释掉。
     location ~* ^.+.(js|ico|gif|jpg|jpeg|pdf|png|css)$ {
          access_log   off;
          expires      7d;
     }

     location ~ .php?$ {
          include           fastcgi_params;
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME    E:/HTML$fastcgi_script_name;
     }        
        
     location ~ /.ht {
          deny  all;
     }

生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生