Đây là quy tắc trong tiếng Anh:Nginx viết lại quy tắc cho CodeIgniter
Any HTTP request other than those for index.php, assets folder, files folder and robots.txt is treated as a request for your index.php file.
Tôi có một file .htaccess
mà làm việc một cách chính xác trên Apache server:
RewriteCond $1 !^(index\.php|assets|files|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Một số kết quả chính xác cho quy tắc này:
example.com
= example.com/index.php
example.com/index.php/welcome
= example.com/welcome
example.com/assets/css/main.css
! =example.com/index.php/assets/css/main.css
tôi đã cố gắng một số công cụ để chuyển đổi từ quy tắc htaccess để nginx quy tắc nhưng tất cả đều không chính xác.
Via http://winginx.com/htaccess (thiếu các quy tắc ngoại lệ cho thư mục tài sản ...):
location/{ rewrite ^(.*)$ /index.php/$1 break; }
Via http://www.anilcetin.com/convert-apache-htaccess-to-nginx/ (lỗi trong $ 1 giá trị):
if ($1 !~ "^(index.php|assets|files|robots.txt)"){
set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
rewrite ^/(.*)$ /index.php/$1 last;
}
Làm thế nào tôi có thể sửa lỗi này? Rất khó để gỡ lỗi quy tắc.
Đây là nginx cấu hình của tôi cho đến nay:
server {
listen 80;
server_name www.example.com example.com;
location/{
try_files $uri $uri/ /index.php?/$request_uri;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Đường dẫn gốc của bạn và đường dẫn đầy đủ với thư mục trình mã hóa của bạn là gì? –