码迷,mamicode.com
首页 > 其他好文 > 详细

nginx规则和ci的支持

时间:2015-01-05 20:21:17      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:

CI框架下nginx重写规则,不再404

http://blog.csdn.net/EI__Nino/article/details/8599304

 

server  
 {  
   listen       80;  
   server_name  222.73.130.124; 
location
/ { index index.html index.htm index.php; root /data0/htdocs/www; if (!-e $request_filename) {   //不含有文件名   #rewrite ^/(.*)$ /index.php?$1 last;     rewrite "^/(.*)$" /index.php last;//这一条很重要 ,添加index.php     # break; }  #rewrite ^/$/index.php last;   #rewrite ^/(?!index\.php|robots\.txt|images|js|styles)(.*)$ /index.php/$1last;   }
location
~ .*\.(php|php5)?$ //让后修正ci所需要的uri参数 { root /data0/htdocs/www; #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info;//这一条很重要 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fcgi.conf; } log_format wwwlogs ‘$remote_addr - $remote_user [$time_local] "$request" ‘ ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" $http_x_forwarded_for‘; access_log /data1/logs/wwwlogs.log wwwlogs; }

 

 

fastcgi_param

http://blog.csdn.net/qq435792305/article/details/8446679


fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;#脚本文件请求的路径
fastcgi_param  QUERY_STRING       $query_string; #请求的参数;如?app=123
fastcgi_param  REQUEST_METHOD     $request_method; #请求的动作(GET,POST)
fastcgi_param  CONTENT_TYPE       $content_type; #请求头中的Content-Type字段
fastcgi_param  CONTENT_LENGTH     $content_length; #请求头中的Content-length字段。

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name; #脚本名称 
fastcgi_param  REQUEST_URI        $request_uri; #请求的地址不带参数
fastcgi_param  DOCUMENT_URI       $document_uri; #与$uri相同。 
fastcgi_param  DOCUMENT_ROOT      $document_root; #网站的根目录。在server配置中root指令中指定的值 
fastcgi_param  SERVER_PROTOCOL    $server_protocol; #请求使用的协议,通常是HTTP/1.0或HTTP/1.1。  

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;#cgi 版本
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;#nginx 版本号,可修改、隐藏

fastcgi_param  REMOTE_ADDR        $remote_addr; #客户端IP
fastcgi_param  REMOTE_PORT        $remote_port; #客户端端口
fastcgi_param  SERVER_ADDR        $server_addr; #服务器IP地址
fastcgi_param  SERVER_PORT        $server_port; #服务器端口
fastcgi_param  SERVER_NAME        $server_name; #服务器名,域名在server配置中指定的server_name

#fastcgi_param  PATH_INFO           $path_info;#可自定义变量

# PHP only, required if PHP was built with --enable-force-cgi-redirect
#fastcgi_param  REDIRECT_STATUS    200;

在php可打印出上面的服务环境变量
如:echo $_SERVER[‘REMOTE_ADDR‘]

 

nginx规则和ci的支持

标签:

原文地址:http://www.cnblogs.com/mitang/p/4204413.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!