您提交的URI不允许在nginx上使用字符codeigniter

时间:2017-08-17 09:54:58

标签: php .htaccess codeigniter nginx

当我在codeigniter中使用查询字符串时,会抛出此错误:

The URI you submitted has disallowed characters.

当我使用apache时,它很好。但在我将项目移至nginx之后,我遇到了这个问题 这是我在apache上的.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^.]*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin
    ErrorDocument 404 index.php
</IfModule>

这是我的nginx配置文件:

server {
    listen 80;
    access_log /var/log/nginx/access.example.com.log;
    error_log /var/log/nginx/error.example.com.log;
    server_name example.com;
    root /home/example/public_html;
    index index.php index.html index.htm;

    error_page 404 index.php;

    location / {
        rewrite ^system.* /index.php?/$1 break;
        rewrite ^application.* /index.php?/$1 break;
        if (!-e $request_filename){
            rewrite ^/([^.]*)$ /index.php?/$1 break;
        }

        proxy_pass http://localhost:8181;
        include proxy.inc;
    }
}

0 个答案:

没有答案