2012-06-29 115 views
2

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

我也尝试了几种不同的.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

我明白了。最后。这是我的.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