CodeIgniter所有页面重定向到主页?

时间:2012-02-12 00:29:37

标签: php javascript apache codeigniter

我已经创建了一个codeIgniter应用程序。它在我的本地工作非常酷,但当我将它部署到主页时,我的所有页面都被重定向到主页。

我有以下目录结构:

--- WWW

- - - - 。htaccess的

------ codeIgniter(应用程序存在于此处)。

我的htaccess读取如下

RewriteEngine on
RewriteCond $1 ^media
RewriteRule ^(.*)$ codeIgnite/$1

RewriteCond $1 !^(index\.php|codeIgnite|images|robots\.txt)
RewriteRule ^(.*)$ codeIgnite/index.php/$1

这是我的config.php $config['base_url'] = "http://localhost/codeIgnite/"; //或者它应该只是http://localhost/

我需要更改一些其他配置设置吗?请帮忙。

我的主页显示得很好。其他页面存在问题。无论我给出什么URL,我都会看到我的主页UI。

3 个答案:

答案 0 :(得分:3)

设置$ config ['uri_protocol'] =“ORIG_PATH_INFO”,解决了这个问题。

答案 1 :(得分:1)

我已使用提供的.htaccess from CodeIgniter,只需将RewriteBase设置为我的子目录即可使其正常工作。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /codeIgnite/

    #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]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    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]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule> 

答案 2 :(得分:0)

您必须将.htaccess放在CodeIgniter文件夹中,并且还必须将文件的最后一行修改为此 RewriteRule ^(。)$ / codeIgniter/index.php/$1或 RewriteRule ^(。)$ /codeIgnite/index.php/$1 你不必在apache配置中什么也不做,只需打开扩展名rewrite_module