2011-09-30 125 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'; 
相关问题