简体   繁体   English

Codeigniter控制器404和路由问题

[英]Codeigniter Controller 404 & routing issues

so I've had experience building codeigniter applications in the past so I'm slightly familiar with the framework 所以我过去有过构建Codeigniter应用程序的经验,所以我对该框架有点熟悉

however anytime prior I've worked directly from the root ( http://domain.com/ ) 但是,在以前的任何时候,我都直接从根目录( http://domain.com/ )工作

I'm currently trying to develop & deploy an application which will be hosted in subfolders ( http://domain.com/foo/bar ) 我目前正在尝试开发和部署将在子文件夹( http://domain.com/foo/bar )中托管的应用程序

I have a decent grasp on routing but I'm not sure what's going on. 我对路由了解得很好,但是我不确定发生了什么。 going to http://domain.com/foo/bar loads without issue, but anytime I try to add a new route such as http://domain.com/foo/bar/myController -- I get a 404. The server is essentially trying to load http://domain.com/foo/bar/myController/index.php versus using the framework controller-- http://domain.com/foo/bar加载没有问题,但是任何时候我尝试添加新的路由(例如http://domain.com/foo/bar/myController)时 ,我都会得到404。实际上是在尝试加载http://domain.com/foo/bar/myController/index.php而不是使用框架控制器-

is this some kind of server configuration or setting? 这是某种服务器配置或设置吗? do I have to do something with htaccess? 我必须对htaccess做点什么? (all I have had to do in the past is scrub index.php out of the URL) (我过去要做的只是从URL中清除index.php)

for the record the issue is not that the controller is broken/missing/named improperly, if I set the default controller to myController the page will load without issue. 记录的问题不是控制器损坏/丢失/命名不正确,如果我将默认控制器设置为myController,则页面将加载而不会出现问题。

I'm a little confused and looking for any kind of advice. 我有些困惑,正在寻找任何建议。 thanks in advance. 提前致谢。

似乎您需要设置base_url (application / config / config.php):

$config['base_url'] = 'http://domain.com/foo/bar';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM