这对我来说很新。我正在将我在codeigniter中制作的网站转移到godaddy共享托管服务器。我可以通过以下网址访问主页:
http://www.example.com
但是当我尝试去其他页面时:
http://www.example.com/about-us/
它会抛出此错误消息:
未找到
在此服务器上找不到请求的网址/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';
CI自动加载文件
$autoload['helper'] = array('url');
09-30-2011更新:
在.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";
答案 0 :(得分:4)
这是一个.htaccess问题。尝试将.htaccess文件更改为:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]
答案 1 :(得分:4)
您更新的.htaccess是对的。你需要做一些小改动。
在.htaccess
文件中更改以下行:
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
并在config.php
$config['uri_protocol'] = 'QUERY_STRING';
答案 2 :(得分:1)
这不是一个godaddy解决方案,但我的WAMP本地主机上的错误相同...
我对此进行了简单的修复,这在我升级WAMPserver后开始发生。它设置了一个新的apache配置,它关闭了rewrite_module。
要修复,我只需点击wamperver icon-> Apache-> Apache Modules-> rewrite_module,并确保勾选。