CodeIgniter只加载默认控制器

时间:2012-06-29 18:12:27

标签: .htaccess codeigniter

我一直在互联网上爬行,其他人使用的解决方案都没有为我工作。问题是默认控制器是唯一要加载的控制器。这里有很多关于这个主题的帖子。但我已经尝试了所有这些,包括尝试$config['uri_protocol']的所有五个设置的主要建议。我已经尝试了所有五个设置,但没有一个工作。

我也尝试了几种不同的.htaccess设置,但这些都没有帮助。这是我试过的一对夫妇。第一个是他们网站上的官方CI .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]

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

#Standard CodeIgniter Rewrite
#-------------------------------------
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] AddHandler cgi-script .pl 

仍然没有运气。有人能告诉我.htaccess和$ config ['uri_protocol']设置的正确组合。所有答案都有所不同。那是因为服务器配置不同吗?

1 个答案:

答案 0 :(得分:1)

我明白了。最后。这是我的.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /materials-library/index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

$config['uri_protocol']设置为REQUEST_URI