热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

针对Yii框架的nginx配置

原文链接:https:www.akii.orgnginx-config-for-yii.html我曾经针对yii制作了个nginx配置,其中包括了以下几项内容:rewrite规则(tr

原文链接:https://www.akii.org/nginx-config-for-yii.html

我曾经针对yii制作了 个nginx配置,其中包括了以下几项内容:

  • rewrite规则(try_file),需要nginx0.8.6版本以上支持。
  • 针对于icon, robots.txt文件的日志优化
  • .svn, .git,等版本控制文件的忽略,以及Mac本身索引文件目录
  • Yii框架本身应该禁止web访问的目录。
  • 图片等静态文件缓存优化

在这里分享一下demo

server {
listen
80;
server_name youdomain.com;
index index.html index.htm index.php;
root /home/wwwroot/htdocs/yii-1.1.8.r3324/demos/blog;
#charset koi8-r;

# 这里的main,是nginx默认的httpd段的一个日志格式定义
access_log /home/wwwlogs/localhost.access.log main
;
#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
#error_page
500 502 503 504 /50x.html;

location
= /favicon.ico {
log_not_found off
;
access_log off;
}

location
= /robots.txt {
allow all
;
log_not_found off;
access_log off;
}

################ Yii framework rule #################
location / {
try_files $uri $uri/ /index.php?$args
;
}

location ~ /(protected|framework|nbproject|themes/\w+/views|index-test\.php) {
deny all
;
# for production
internal
;
log_not_found off;
access_log off;
}
################ for Yii framework end #################

location ~ \.php$ {
fastcgi_pass php
;
fastcgi_index index.php;
include fastcgi.conf;
}

# deny access to .htaccess files
, if Apache's document root
# concurs with nginx's one
#
location ~ /(\.svn|\.git|\.ht|\.DS) {
deny all
;
internal;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max
;
log_not_found off;
}

}

location / {
try_files $uri $uri/ /index.php?$args;
}
不加$args也可以吧?

作者答:不加的话,比如你url中含有?a=b这种get参数,可能就传递不过去了。

 


推荐阅读
author-avatar
dghghjkk_952
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有