2011-04-20 22 views
0

我似乎無法在GoDaddy上正確設置CodeIgniter。我試圖在'wecome'控制器內創建一個新函數。但我無法在任何地方訪問它。GoDaddy服務器上的CodeIgniter和URI問題

http://domain.com/test (No response) <- why doesn't this work 
http://domain.com/index.php/welcome/test (No response) <- why doesn't this work 

而只是給你的默認歡迎頁面是如何解決的想法:

http://domain.com/ (resolves to welcome page aka 'index' function) 
http://domain.com/index.php/ (resolves to welcome page aka 'index' function) 
http://domain.com/index.php/welcome (No response) <- why doesn't this work? 
http://domain.com/index.php/welcome/index (No response) <-why doesn't this work? 

我怎樣才能得到這個建立正確?

+0

你有雙重檢查的CodeIgnitor論壇?他們非常活躍,可能會有更多的GoDaddy用戶幫助 - http://codeigniter.com/forums/ – philm 2011-04-20 09:17:10

回答

5

步驟1在您的.htaccess文件的根目錄設置此:

RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
RewriteCond %{REQUEST_URI} ^application.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
RewriteCond %{HTTP_HOST} ^mydomain.com [NC] 
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301] 

第2步打開/system/application/config/config.php文件,並確保以下兩個選項進行設置。

$config['index_page'] = 「」; 
$config['uri_protocol'] = 「AUTO「; 

希望這對我有所幫助。

+0

我想到了你的第2步,CI的應用程序文件夾位於系統文件夾中。如果應用程序文件夾現在與系統文件夾處於同一級別,該怎麼辦? (現在在CI2中是這樣的)。我們應該如何重寫.htaccess文件? – 2012-09-27 20:40:39

+0

謝謝你......你爲我節省了大量的trobble – Binaryrespawn 2013-10-09 18:36:28

1

你可以尋找這個問題的可能的地方是,.htaccess文件(從未使用過godaddy,但是我看到其他人對這個託管公司有不同的.htaccess規則),接下來是你的application/config/config.php文件和uri_protocol,試驗這個(你可以傳遞的值很少),也取決於你的CI版本,你可以嘗試擴展CI_URI或CI_Router類,以便將邏輯插入某處,但正如我所說的那樣取決於你使用的CI版本,從1.7到2.0.2,他們對這些負責路由和uri匹配的類進行了少許更改,如果你找不到解決方案,請回來發佈更多信息。

+0

我認爲代碼現在不適用於2.1.2。 – 2012-09-28 06:15:54

0

嘗試把此行:

@ini_set('cgi.fix_pathinfo', 0);

在你的index.php文件。也可以在config.php中使用您的URI_PROTOCOL設置。

0

爲此,打開您的應用程序/配置/ config.php文件,更改此:

$config['index_page'] = "index.php"; 

要這樣:

$config['index_page'] = "index.php?";