將我的應用程序移動到Nginx服務器之後,事情剛剛爆炸。 我的網站被加載,但是當我嘗試訪問一些控制器返回404找不到。 閱讀大量的文章如何配置nginx.conf但沒有成功。Nginx + Codeigniter重寫
這裏是我的nginx.conf
server {
listen 80;
server_name example.com;
root /var/www/html/travel;
index index.php;
# Enable rewrite error log
error_log /var/log/nginx/travel.error_log debug;
rewrite_log on;
# Any HTTP request other than those for assets folder, files folder and robots.txt
# is treated as a request for your index.php file.
location/{
try_files $uri $uri/ /index.php?/$request_uri;
}
location ~* ^/(assets|files|robots\.txt) { }
# Deny access to .htaccess files, if Apache's document root
# concurs with Nginx's one
location ~ /\.ht {
deny all;
}
}
奇怪的是,在error.log中沒有錯誤。
這裏是我笨的config.php
$config['base_url'] = 'http://example.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
錯誤日誌將列出導致404錯誤的路徑名。另外,你沒有PHP配置。你需要像'php-fpm'這樣的東西。見[這](https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/) –
嗯,我做到了。在服務器內部添加這個內容:include fastcgi.conf;但是是一樣的 – IdlleF
請重新上傳你的配置! – uzsolt