【发布时间】:2011-09-06 05:44:02
【问题描述】:
我使用 Codeigniter 的 _remap 函数将所有 url 重新映射到 www.website.com。这适用于 99% 的情况,但我希望它忽略某些 URL(特别是 /admin、/contact、/submit、/top、/browse)。这些 URL 包含我想要显示的内容。
我将如何实现这一目标?
public function _remap($urlname)
{
if($urlname == "index") {
// If this is the index, redirect to the most recent startup
redirect("s/".$this->Startup_model->getMostRecent(), 'refresh');
} else {
// If they didn't go to the index, find the startup they were after
$id = $this->Startup_model->matchName($urlname);
// Check to see if the name they entered was a real startup, if not redirect to missing page
if($id == null) {
$data['urlname'] = $urlname;
$this->load->view('header/header');
$this->load->view('content/missing', $data);
$this->load->view('footer/footer');
} else {
// They got the name right! Load the page...
$data['values'] = $this->Startup_model->buildStartup($id);
// If there was no next startup avaiable, pass that info through
$next = $this->Startup_model->findNext($id);
if($next == null) {
$next = '343z61v';
}
// If there was no previous startup avaiable, pass that info through
$previous = $this->Startup_model->findPrevious($id);
if($previous == null) {
$previous = '343z61v';
}
$data['next'] = $next;
$data['previous'] = $previous;
$this->load->view('header/header');
$this->load->view('content/startup', $data);
$this->load->view('footer/footer');
}
}
}
【问题讨论】:
-
你可以把你的 _remap 函数放进去吗?
标签: codeigniter routes