首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >codeigniter 404错误

codeigniter 404错误
EN

Stack Overflow用户
提问于 2011-07-03 06:54:13
回答 1查看 2.5K关注 0票数 1

我开了一个codeigniter网站。我的默认控制器是$route' default _ controller‘= "login";在routes.php中

在config.php中,我的基本URL是$config' base _url‘= 'http://digimed.net/sandbox/'

场景A我在URL栏中输入http://digimed.net/sandbox/,如期获得登录控制器的索引方法。

场景B我输入了类似于http://digimed.net/sandbox/login的内容,当我期望得到与场景A相同的结果时,我得到了一个404错误。

事实上,我不能访问登录控制器中的任何函数。我每次都会收到404错误。

在路线或会议中有什么需要更改的吗?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-03 07:19:20

如果任何人感兴趣,我通过在网站路由目录( codeigniter路由目录所在的位置)中添加以下.htaccess文件解决了这个问题。

代码语言:javascript
复制
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /system_admin

#Removes access to the 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
#Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6560040

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档