我可以手动更改我的Codeigniter脚本中的每一段代码(这是巨大的),或者我可以使用.htaccess来完成。
有没有办法更改网址的一部分,将其屏蔽,以便www.page.com/athlete
成为www.page.com/product
?但是,我不希望进入代码,这意味着导致www.page.com/athlete
的链接仍然可以正常工作,只有差异会出现在显示www.page.com/product
的网址栏中
答案 0 :(得分:1)
你可以用Routes做到这一点。将其添加到./application/config/routes.php
$route['product'] = 'athlete';
现在,无论何时访问/产品,它都会加载/运动员控制器。
你可能会尝试这样的事情。检查URI段是否为“运动员”,如果是,则将它们重定向到您已设置为指向运动员控制器的“产品”。像这样;
public function __construct()
{
// Check if the URI is athlete, if it is, redirect them to product
// But, product is this controller, which is defined in the routes
if ($this->uri->segment(2) == 'athlete')
{
redirect('product');
}
}