【问题标题】:Site developed in Codeigniter only loads home pageCodeigniter 开发的站点只加载主页
【发布时间】:2011-01-05 09:25:57
【问题描述】:

我正在尝试将使用 Codeigniter 开发的网站从一台主机移动到另一台主机。主机之间的唯一区别是,要迁移站点的服务器是 Windows 服务器(安装了 PHP 等),而新服务器是 Linux。

但是,当我上传网站并更改所有 url 引用时,该网站只加载主页。

新站点的地址是http://pioneer.xssl.net/~admin341/

有一个htaccess文件,内容如下:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

# 如果我们没有安装 mod_rewrite,所有 404 的 # 可以发送到 index.php,一切正常。 # 提交人:ElliotHaughin

ErrorDocument 404 /index.php

config.php 中与 url 相关的行是:

$config['base_url'] = "http://pioneer.xssl.net/~admin341/index.php/";
$config['index_page'] = "";

加上开发者(我的前任)编写了一个 url 帮助文件:

function base_url($includeIndexPHP = true)
{       
    if($includeIndexPHP)
    {
        $CI =& get_instance();      
        return $CI->config->slash_item('base_url');
    }
    else
    {
       return 'http://pioneer.xssl.net/~admin341/';
    }
}

任何想法将不胜感激。谢谢。

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    您可能需要更改 $config['uri_protocol'] 以使其在您的实时站点上运行。这通常是 CodeIgniter 中“仅主页”路由问题的原因。

    最常见的是 REQUEST_URI,但有时 PATH_INFO 效果更好。

    【讨论】:

    • 谢谢菲尔。以前从来没有遇到过这种情况,但很管用。
    • 你太棒了!在我找到这个解决方案之前,我敲了将近 4 个小时。谢谢
    猜你喜欢
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 2014-04-19
    • 2020-04-26
    • 1970-01-01
    • 2013-02-06
    • 2023-03-11
    相关资源
    最近更新 更多