【问题标题】:Codeigniter + Nginx 404 not found未找到 Codeigniter + Nginx 404
【发布时间】:2016-06-23 23:18:09
【问题描述】:

我在使用 nginx 配置 Codeigniter 2 时遇到问题。 登陆页面没有问题。 但是找不到永久链接。

404 未找到

nginx

Htaccess:

IndexIgnore *
Options +FollowSymlinks
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

我该怎么办?

非常感谢。

【问题讨论】:

  • 也向我们展示代码

标签: codeigniter url nginx http-status-code-404 permalinks


【解决方案1】:

澄清一下,.htaccess 文件用于 apache 服务器,因此对您的 nginx 服务器没有任何作用。您必须配置/etc/nginx/nginx.conf 文件。在此之前你应该备份你当前的文件cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup

然后,试试这个代码:

# nginx configuration
location / {
    if (!-e $request_filename){
        rewrite ^(.*)$ /index.php/$1 break;
    }
}

免责声明:我使用this在线服务获取代码。

【讨论】:

  • 试试nginx推荐的this配置
【解决方案2】:

Nginx 检查加载的类的大小写和文件名。

例如:类名是 Login。文件名为 login.php 结果:404。

将文件名更改为 Login.php,nginx 将按预期开始工作。

Imp 注意:类名和文件名的大小写应该匹配。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-27
    • 2018-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-27
    • 2018-05-03
    相关资源
    最近更新 更多