這裏Nginx的重寫規則是英文的規則:對於笨
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.
我有一個.htaccess
文件Apache服務器上正常工作:
RewriteCond $1 !^(index\.php|assets|files|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
此規則的一些正確的結果:
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
我嘗試了一些工具來htaccess的規則轉換爲nginx的規則,但所有是不正確的。
通過http://winginx.com/htaccess(缺少資產文件夾中的例外規則...):
location/{ rewrite ^(.*)$ /index.php/$1 break; }
通過http://www.anilcetin.com/convert-apache-htaccess-to-nginx/(錯誤$ 1的值):
if ($1 !~ "^(index.php|assets|files|robots.txt)"){
set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
rewrite ^/(.*)$ /index.php/$1 last;
}
我該如何解決這個問題?調試規則真的很難。
這是到目前爲止我的nginx的配置:
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;
}
}
什麼是您的codeigniter目錄的根路徑和完整路徑? –