在共享托管服务器上使用 codeigniter 感到困惑 [英] Puzzled using codeigniter on shared hosting server
问题描述
这对我来说是新的.我正在将我在 codeigniter 中创建的站点转移到 Godaddy 共享托管服务器.我可以通过以下方式进入主页:
This ones a new on me. I'm transferring a site I made in codeigniter to a godaddy shared hosting server. I can get to the home page with:
http://www.example.com
但是当我尝试转到其他页面时:
But when I try to go to the other pages like:
http://www.example.com/about-us/
它向我抛出此错误消息:
It throws me this error message:
未找到
在此服务器上找不到请求的 URL/example/index.php/about-us/.
The requested URL /example/index.php/about-us/ was not found on this server.
此外,在尝试使用 ErrorDocument 处理请求时遇到 404 Not Found 错误.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
如果我使用:
http://www.example.com/index.php/about-us/
页面看起来像白天一样清晰.
The page appears as clear as day.
我已经查找了 CI 解决方法,但我的网站更多的是静态页面而不是动态页面.
I have looked up CI workaround , but my site is more of static pages then dynamic pages.
总的来说,我的问题是,我做错了什么,这与拥有 Godaddy 共享主机帐户有什么关系吗?
Overall, my question is, what am I doing wrong and does this have anything to do with having a godaddy shared hosting account?
.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中使用:
In the .htaccess use:
# 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 配置文件中:
In the CI config file:
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";
来源:codeigniter.com/wiki/Godaddy_Installaton_Tips
推荐答案
这是一个 .htaccess 问题.尝试将您的 .htaccess 文件更改为:
It's an .htaccess issue. Try changing your .htaccess file to:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]
这篇关于在共享托管服务器上使用 codeigniter 感到困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!