Codeigniter在一台服务器上工作,但在另一台服务器不工作


Codeigniter working on one server but not on another server

我使用codeigniter开发了一个web应用程序。在我的本地主机中,它工作正常。但是,当我将它托管到实时服务器(共享服务器)时,它不起作用。当我在实时服务器上调用主URL时,我得到了主页,但通过控制器的任何URL都不工作

调用URL时"http://my_domain.in/pages/second_page"获取以下错误

The requested URL /my_domain.in/my_domain.in/index.php/pages/second_page was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache Server at my_domain.in Port 80

我在错误字符串URL上注意到我的域名重复,但在实际的URL上却不是这样,index.php也被找到了。所以我多次更改.htaccess代码来解决这个问题。此时"错误"消息上的URL正在更改,但没有成功的结果。

终于我把它托管在我朋友的服务器上了。这一次它可以像我的本地主机一样正常工作。你能告诉我我的服务器会出什么问题吗?在该服务器上使用codeigniter时,有什么可以启用或禁用的吗?此服务器中从未使用过codeigniter框架。

为了得到更好的答案,您需要提供托管提供商名称。您可以尝试使用以下.htaccess.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1

看起来你在隐藏index.php,但错误是提到了它===>/my_domain.in/my_domain/in/index.php/pages/second_page未找到

你也在配置页面中删除了它吗?''config''config.php

确保$config['index_page']='';并添加带有以下行的.htaccess文件


    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L]

我在Windows和Linux机器上测试时遇到了这个问题,并像这样调整了config.php。


    if (file_exists(FCPATH.'.htaccess')) {
     $config['index_page'] = '';
    }
    else {
     $config['index_page'] = 'index.php';
    }

第一个没有.htacess文件的teste如果一切顺利,请将.htaccess文件放在根目录中,然后重试。

如果你仍然得到这个错误,看看你已经编码的链接,看看里面是否提到了index.php。