我面临一个URI路由问题,我相信这里有人可以帮我解决。我已经在谷歌上搜索到了足以让我的大脑冻结的程度。好的,这是的情况
CodeIgniter版本:2.1.3
我已经在application/config/routes.php 中路由了两个页面
$route['sites/(:any)']='个人资料/专业人员';
$route['sites/(:any)/(:any;
我有一个名为:Profiles 的控制器
档案内部的一种方法:
public function professional(){
$user = $this->uri->segment(3);
$current_page = $this->uri->segment(4);
switch ($current_page) {
case 'about':
$this->data['content'] = 'user_sites/about_view';
break;
default:
$this->data['content'] = 'user_sites/home_view';
break;
}
$this->load->view('my_view',$this->data);
}
现在如果我加载
www.mysite.com/sites/some_user/
它的负载很好。路由也很好。(我有htaccess文件来删除index.php)
但是当我尝试加载时
www.mysite.com/sites/some_user/about/
它无法加载(空白页)。然而,这条路线实际上是可行的。因为当我加载时
www.mysite.com/sites/index.php/some_user/about/
它使用我在控制器中的开关加载。
所以我想我必须在.htaccess文件中添加一两行代码?有人能帮忙吗?我当前的.htaccess文件看起来像这个
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
ModRewrite也打开。
提前非常感谢。。。
我认为您在计算分段和你的编解码器在第4段中查找about关键字,这样它就会在这个URL中找到它www.mysite.com/sites/index.php/some_user/关于
注意,这里的index.php并不是真正的索引页,因为它在站点控制器之后,它将g称为一个段(因此它不是htaccess。Issue)
如果删除index.phpwww.mysite.com/sites/some_user/about
About位于段号3