簡體   English   中英

nginx - 所有網址的codeigniter 404錯誤

[英]nginx - codeigniter 404 error for all urls

我已將我的文件(Codeigniter Framework)上傳到abcd目錄(url:example.com/abcd)。 內部的所有鏈接都給出404錯誤。 為了刪除index.php,我已將此nginx.conf文件放在我的根目錄中(在服務器上:/.../abcd/)以下是nginx.conf文件的代碼:

server {  
    server_name example.com/abcd;
    root /..../abcd;

    index index.html index.php index.htm;

    # set expiration of assets to MAX for caching
    location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
        expires max;
        log_not_found off;
    }

    location / {
        # Check if a file exists, or route it to index.php.
        try_files $uri $uri/ /index.php;
    }

    location ~* \.php$ {
        fastcgi_pass example.com/abcd;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

}

在apache中,使用重寫很容易,我現在堅持使用nginx。 請幫忙,我是第一次使用nginx

請嘗試以下代碼..取自https://serverfault.com/questions/695521/codeigniter-in-subdirectory-on-nginx-404

 location /abcde/ {
        alias  /var/www/abcde/;
        try_files $uri $uri/ /abcde/index.php;

        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_index   index.php;
            fastcgi_pass    backend;
            include /etc/nginx/fastcgi_params;
            fastcgi_param   SCRIPT_FILENAME $request_filename;
        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM