我对CodeIgniter相当陌生,并且完成了我的第一个项目。但是,在我将其放在我的托管站点上之前,我想使用CodeIgniter在config文件夹中提供的routes.php文件清理URL。简单的URL路由不能与CodeIgniter一起使用
我的网站会加载使用以下网址:
http://fakehost:8888/TheWorksPlumbing/index.php/theWorksPlumbingController/index/home
http://fakehost:8888/TheWorksPlumbing/index.php/theWorksPlumbingController/index/about
http://fakehost:8888/TheWorksPlumbing/index.php/theWorksPlumbingController/index/services
,它也将使用默认的控制器的网址加载网页:http://fakehost:8888/TheWorksPlumbing/
不过,我想对每一个url该网站的页面,但不能得到它的工作。例如,我想有:
http://fakehost:8888/TheWorksPlumbing/home
http://fakehost:8888/TheWorksPlumbing/about
http://fakehost:8888/TheWorksPlumbing/services
下面是theWorksPlumbingController控制文件中的代码:
class TheWorksPlumbingController extends CI_Controller {
public function index($page = 'home'){
if (!file_exists('application/views/'.$page.'.php')) {
show_404();
}
$this->load->view('templates/header');
$this->load->view($page);
$this->load->view('templates/footer');
}
}
这里是我的routes.php文件文件中的代码不工作:
$route['default_controller'] = "theWorksPlumbingController";
$route['404_override'] = '';
$route['(:any)'] = "index.php/theWorksPlumbingController/index";
我需要添加或更改什么才能让网站加载/ home或/ about或/ services?
快速完整性检查,通过
而且路由可达什么你的mod_rewrite规则是什么样子的? – David 2013-03-21 18:49:27
大卫,我没有触及mod_rewrite规则。你的意思是.htaccess文件吗?它说:拒绝所有在那里..我认为这是不好的? – ErinSKabbash 2013-03-21 18:53:13
看着你回答的问题,它似乎不像你有.htaccess下的mod_rewrite规则。否则,我强烈建议你花一些时间阅读Apache的用户指南 - http://httpd.apache.org/docs/2.2/它们相当干燥,但重要的是你对Apache可以为你做什么或可能做什么有所了解。 – David 2013-03-21 21:11:17