.htaccess 在共享主机服务器上使用codeigniter

.htaccess 在共享主机服务器上使用codeigniter,.htaccess,codeigniter,mod-rewrite,.htaccess,Codeigniter,Mod Rewrite,这对我来说是新的。我正在将我在codeigniter中创建的站点转移到godaddy共享托管服务器。我可以通过以下方式访问主页: http://www.example.com 但当我试图转到其他页面时,如: http://www.example.com/about-us/ 它向我抛出以下错误消息: 找不到 在此服务器上找不到请求的URL/example/index.php/about-us/ 此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误 如果我使用:

这对我来说是新的。我正在将我在codeigniter中创建的站点转移到godaddy共享托管服务器。我可以通过以下方式访问主页:

http://www.example.com
但当我试图转到其他页面时,如:

http://www.example.com/about-us/
它向我抛出以下错误消息:

找不到

在此服务器上找不到请求的URL/example/index.php/about-us/

此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误

如果我使用:

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';
$autoload['helper'] = array('url');
CI自动加载文件

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'QUERY_STRING';
$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"; 

来源:

这是一个.htaccess问题。尝试将.htaccess文件更改为:

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

这不是godaddy解决方案,但在我的WAMP localhost上出现了相同的错误

我对此有一个简单的修复,这是在我升级WAMPserver之后开始的。它设置了一个新的apache配置,并关闭了“重写”模块


要解决这个问题,我只需左键单击wamperver图标->Apache->Apache模块->重写模块,并确保勾选了该选项。

您的更新。htaccess是正确的。你需要一点零钱。 更改
.htaccess
文件中的以下行:

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

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

嗯,试着看看这篇文章()和相关的讨论()。2011年的一些帖子可能会有所帮助。另外,请尝试在
上重写引擎后的新行中添加
选项+FollowSymLinks
。如果您从我的链接中找到它,您可以投票或接受我的答案吗?如果没有,请在此处发布解决方案,以便其他人可以看到。谢谢:)不要在标题或问题中添加“已解决”或类似内容。请将您的解决方案张贴在下面的答案中。谢谢