2011-09-30 131 views
4

這對我來說是一個新的。我將我在codeigniter中創建的網站轉移到godaddy共享託管服務器。我能到主頁用:共享託管服務器上使用codeigniter困惑

http://www.example.com 

但是當我嘗試去其他頁面,如:

http://www.example.com/about-us/ 

它拋出我這個錯誤消息:

未找到

在此服務器上未找到請求的URL /example/index.php/about-us/。

此外,嘗試使用ErrorDocument處理請求時遇到404未找到錯誤。

如果我使用:

http://www.example.com/index.php/about-us/ 

的頁面出現像白天一樣清晰。

我已經查找了CI解決方法,但我的網站更多的是靜態頁面,然後是動態頁面。

總的來說,我的問題是,我做錯了什麼,這是否有一個與godaddy共享託管帳戶有什麼關係?

的.htaccess

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

CI配置文件

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

CI自動加載的文件

$autoload['helper'] = array('url'); 

2011年9月30日更新:

在.htaccess使用:

# Options 
Options -Multiviews 
Options +FollowSymLinks 

#Enable mod rewrite 
RewriteEngine On 
#the location of the root of your site 
#if writing for subdirectories, you would enter /subdirectory 
RewriteBase/

#Removes access to CodeIgniter 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 
RewriteCond $1 !^(index\.php|images|robots\.txt|css) 

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

在CI配置文件:

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

來源:codeigniter.com/wiki/Godaddy_Installaton_Tips

+0

不要把「解決」,或在標題或類似的問題。請將您的解決方案作爲下面的答案發布。謝謝。 – Sparky

回答

4

這是一個.htaccess問題。試着改變你的.htaccess文件:

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

我試過了,它仍然給我相同的錯誤信息。 – blackbull77

+2

嗯。試着看這篇文章(http://codeigniter.com/wiki/Godaddy_Installaton_Tips)和相關的討論(http://codeigniter.com/forums/viewthread/133292/)。 2011年有一些帖子可能會有所幫助。 – birderic

+0

另外,嘗試在'RewriteEngine on'之後的新行添加'Options + FollowSymLinks'。 – birderic

1

這不是一個GoDaddy的解決方案,但在我的WAMP本地主機同樣的錯誤......

我有一個簡單的解決這一點,它開始後,我出現升級了我的WAMPserver。它已經建立了一個新的Apache配置,並關閉了rewrite_module。

要解決,我只需要點擊wamperver圖標 - > Apache-> Apache模塊 - > rewrite_module並確保打勾。

4

您更新的.htaccess是正確的。你需要一個小的改變。 變化下面一行放在.htaccess文件:

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

,並在您config.php

$config['uri_protocol'] = 'QUERY_STRING'; 
相關問題