首页 > 代码库 > nginx规则和ci的支持

nginx规则和ci的支持

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=123fastcgi_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; #客户端IPfastcgi_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的支持