【发布时间】:2016-05-08 22:01:04
【问题描述】:
在我将我的应用程序移动到 Nginx 服务器之后,事情就炸了。 我的网站已加载,但是当我尝试访问某些控制器时返回 404 未找到。 阅读了很多文章如何配置 nginx.conf 但没有成功。
这是我的 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中没有错误。
这是我的 Codeigniter config.php
$config['base_url'] = 'http://example.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
【问题讨论】:
-
错误日志将列出导致 404 错误的路径名。此外,您没有 PHP 配置。你需要像
php-fpm这样的东西。见this -
好吧,我做到了。添加内部服务器块:包括 fastcgi.conf;但是是一样的
-
请重新上传您的配置!
标签: php codeigniter nginx rewrite