用于URL参数的codeigniter的Nginx重写规则

时间:2016-07-24 08:54:28

标签: php .htaccess codeigniter mod-rewrite nginx

我为nginx服务器进行了以下配置代码点火器并正常工作,遗憾的是有一种情况不起作用。

当我使用参数Like

请求URL时

servername.com/ControllerName/methodName?param=value  我找不到第404页

服务器配置:

server {
    # access from localhost only
    listen       127.0.0.1:80;
    server_name  serverName.com;
    root         API;


    log_not_found off;
    charset utf-8;

    access_log  logs/accessservername.log main;
index index.php;
    # handle files in the root path /www
     location / {
         try_files $uri $uri/ /index.php?$args;
     }    

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   API;
    }


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9100
    #
    location ~ \.php$ {
        try_files      $uri =404;
        fastcgi_pass   php;
        fastcgi_index  index.php;  
        #fastcgi_param  PHP_FCGI_MAX_REQUESTS 1000;
        #fastcgi_param  PHP_FCGI_CHILDREN 100;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param   REMOTE_ADDR $http_x_real_ip;
        include        fastcgi_params;

    }

    # add expire headers and speed up image access with a vary header
    location ~* ^.+.(gif|ico|jpg|jpeg|png|flv|swf|pdf|mp3|mp4|xml|txt|js|css)$ {
        expires 30d;
        add_header Vary Accept-Encoding;
    }

    # only allow these request methods
    if ($request_method !~ ^(GET|HEAD|POST)$ ){ return 405; }

}

0 个答案:

没有答案