2012-04-28 47 views
7

我在subdirecotry www.siteb.com/rexona安装CI笨没有输入文件中指定的错误

我里面www.siteb.com/rexona的.htaccess:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /rexona 

#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 
#This last condition enables access to the images and css folders, and the robots.txt file 
#Submitted by Michael Radlmaier (mradlmaier) 
RewriteCond $1 !^(index\.php|images|robots\.txt|css) 
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 

ErrorDocument 404 /index.php 
</IfModule> 

在config.php:

$config['index_page'] = ''; 
$config['base_url'] = ''; 
$config['uri_protocol'] = 'AUTO'; 

每当我尝试访问控制器我得到没有输入文件中指定。但它确实加载了默认控制器,但我无法访问默认控制器中的任何方法。

有什么想法? 谢谢。

回答

24

您的uri_protocol需要设置为 - 至少将其设置为自动。

您得到的错误是因为PHP作为CGI运行,这意味着您需要将URL重写传递给index.php?/$1(请注意问号)。

+0

如果我将代码移动到PHP作为Apache模块运行的服务器,这仍然可行吗? – 2012-11-25 15:50:42

+0

@Peter如果'uri_protocol'configuration设置为AUTO,我会怀疑它的确如此。但是,当服务器使用另一种类型的实现时,我不建议使用特定于服务器设置。 – Repox 2012-11-25 15:54:37

+0

谢谢,它在现场托管和错误相关的错误错误无法加载动态库消失 – 2015-05-24 09:47:33

1

您的$config['uri_protocol']不应该是空的。缺省值为AUTO,传入一个空字符串会破坏核心URI类,该类用于通过路由器类路由请求。

/* 
|-------------------------------------------------------------------------- 
| URI PROTOCOL 
|-------------------------------------------------------------------------- 
| 
| This item determines which server global should be used to retrieve the 
| URI string. The default setting of 'AUTO' works for most servers. 
| If your links do not seem to work, try one of the other delicious flavors: 
| 
| 'AUTO'   Default - auto detects 
| 'PATH_INFO'  Uses the PATH_INFO 
| 'QUERY_STRING' Uses the QUERY_STRING 
| 'REQUEST_URI'  Uses the REQUEST_URI 
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO 
| 
*/ 
$config['uri_protocol'] = 'AUTO'; 

正如评论说:“如果你的链接似乎不工作,尝试其他口味的美味之一”
空字符串不是其中的一种,它最终会尝试从$_SERVER['']中读取,通常这是空的。

+0

嗨,我试过所有的选择,但没有成功....可能是什么问题?是.htaccess还是CI配置或服务器...? – fjckls 2012-04-28 08:34:41

+0

把它留在汽车上。出于某种原因,我认为将其留空会将其设置为默认值。 – fjckls 2012-04-28 10:03:07

+0

从查看CI的源代码,我没有看到为什么空字符串不能完成与“AUTO”相同的工作的原因。我个人认为这是有道理的,并与其他配置项目更加一致,这只是他们选择做的方式,我猜。 – 2012-04-29 00:55:39

3

GoDaddy的托管,似乎固定on.htaccess,我自己也正在改变:

RewriteRule ^(.*)$ index.php/$1 [L] 

RewriteRule ^(.*)$ index.php?/$1 [QSA,L] 
+0

这对我有用。非常感谢。 – kanchan 2016-05-04 04:42:13

0

我得到hostinger免费帐户相同的错误,解决与所提出的问题上面的jhon foo。

我的.htaccess

RewriteBase /MY_SUBFOLDER_UNDER_HTML_DIRECTORY/ 
RewriteEngine on 

RewriteBase /mY_subfolder/ 
RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$0 [QSA,L] 

这项工作很好,非常感谢!

相关问题