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

Nginx配置文件server部分
 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;//这一条很重要

		#  break;
             }
   	 rewrite ^/$/index.php last;
    	#rewrite ^/(?!index\.php|robots\.txt|images|js|styles)(.*)$ /index.php/$1last;
     }
   location ~ .*\.(php|php5)?$
    #location ~ \.php
    {

       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;
  }


你可能感兴趣的:(Linux,Nginx,PHP)