【问题标题】:Codeigniter - NGINX How to Remove index.phpCodeigniter - NGINX 如何删除 index.php
【发布时间】:2021-03-18 15:37:37
【问题描述】:

问题详情

描述:添加 nginx custom.conf 对我不起作用。它显示以下错误

404 Not Found
nginx/1.18.0

但是如果我在 URL 中的类名之前添加 index.php/ 那么它工作正常

请告诉我如何使用 Elastickbeanstalk + nginx + codeigniter 设置从 url 中删除 index.php

以下是我的申请的全部细节

版本

PHP 7.4
Codeignter 3.10

部署设置

AWS
ElasticBeanstalk
NGINX

我的应用程序设置

.platform
  -nginx
     -conf.d
        -custom.conf
-Application
-Controller
-Views
-Model
...
...
..

自定义配置 custom.conf

files:
  /etc/nginx/conf.d/proxy.conf:
    mode: "000644"
    owner: root
    group: root
    content: |
      server {
        server_name http://domain.tld/;

        root /var/www;
        index index.html index.php;

        # set expiration of assets to MAX for caching
        location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
                expires max;
                log_not_found off;
        }

        location / {
                # Check if a file or directory index file exists, else route it to index.php.
                try_files $uri $uri/ /index.php;
        }

        location ~* \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                include fastcgi.conf;
        }
    }

我的 config.php

$config['base_url'] = "http://domain.tld/";
$config['index_page']       = "";
$config['uri_protocol']     = "REQUEST_URI";

请帮忙!!!

【问题讨论】:

  • 您查看过您的日志文件吗?
  • 感谢您的回复,是的 nginx logs "2020/12/07 12:41:28.905128 [INFO] 执行指令:GetTailLogs 2020/12/07 12:41:28.905135 [INFO] 尾日志。 .. 2020/12/07 12:41:28.906315 [INFO] 运行命令 /bin/sh -c tail -n 100 /var/log/eb-engine.log"

标签: php codeigniter nginx


【解决方案1】:

我通过为代理配置输入正确的路径解决了这个问题。

谢谢 Xaver!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-05
    • 1970-01-01
    • 2011-07-09
    • 1970-01-01
    • 2011-01-18
    • 1970-01-01
    • 2016-07-26
    • 2012-10-30
    相关资源
    最近更新 更多