【问题标题】:Problem with CodeIgniter and URI on GoDaddy serversGoDaddy 服务器上的 CodeIgniter 和 URI 问题
【发布时间】:2011-04-20 04:04:46
【问题描述】:

我似乎无法在 GoDaddy 上正确设置 CodeIgniter。我尝试在“wecome”控制器中创建一个新函数。但我无法在任何地方访问它。

http://domain.com/test   (No response) <- why doesn't this work
http://domain.com/index.php/welcome/test   (No response) <- why doesn't this work

只是为了让您了解默认欢迎页面的解析方式:

http://domain.com/   (resolves to welcome page aka 'index' function)
http://domain.com/index.php/   (resolves to welcome page aka 'index' function)
http://domain.com/index.php/welcome   (No response) <- why doesn't this work?
http://domain.com/index.php/welcome/index (No response) <-why doesn't this work?

如何正确设置?

【问题讨论】:

  • 您是否仔细检查过 CodeIgnitor 论坛?他们非常活跃,可能有更多 GoDaddy 用户可以提供帮助 - codeigniter.com/forums

标签: php codeigniter


【解决方案1】:

步骤 1. 在根目录的 .htaccess 文件中设置:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]

步骤 2. 打开 /system/application/config/config.php 文件并确保设置了以下两个选项。

$config['index_page'] = “”;
$config['uri_protocol'] = “AUTO“;

希望这会有所帮助。

【讨论】:

  • 我在你的步骤2中计算,CI的应用程序文件夹位于系统文件夹中。如果应用程序文件夹现在与系统文件夹处于同一级别怎么办。 (现在在 CI2 中就是这样)。我们应该如何重写.htaccess文件?
【解决方案2】:

您可以查找此问题的可能位置是 .htaccess 文件(从未使用过 godaddy,但我看到其他人对该托管公司有不同的 .htaccess 规则),接下来是您的 application/config/config.php 文件和 uri_protocol,用这个做实验(你可以传递的值很少),也取决于你的 CI 版本,你可以尝试扩展 CI_URI 或 CI_Router 类以便在某处插入你的逻辑,但正如我所说,这将很大程度上取决于在您使用的 CI 版本上,从 1.7 到 2.0.2,他们对这些负责路由和 uri 匹配的类进行了一些更改,如果您找不到解决方案,请返回并发布更多信息。

【讨论】:

    【解决方案3】:

    试着把这条线:

    @ini_set('cgi.fix_pathinfo', 0);

    在您的 /index.php 文件中。还可以在 config.php 中使用 URI_PROTOCOL 设置。

    【讨论】:

      【解决方案4】:

      为此,请打开您的 application/config/config.php 文件并进行更改:

      $config['index_page'] = "index.php";
      

      到这里:

      $config['index_page'] = "index.php?";
      

      【讨论】:

        猜你喜欢
        • 2018-03-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-20
        • 1970-01-01
        • 1970-01-01
        • 2015-04-27
        相关资源
        最近更新 更多