2012-04-28 32 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] 

這項工作很好,非常感謝!

相關問題