我想用一个 Controller 处理所有请求并且我有一个路由
$route['(:any)'] = 'links/index/$1';
和我数据库中的表(下面的截图)
所以当 URL 是 mydomain.com/first-article 时,我从数据库 Controller 、操作和表 ID 中进行选择,我想重定向到文章 Controller 、文章操作并传递 table_id。 我该怎么做?
我还需要保留 URL
mydomain.com/first-article
然后我用 redirect() 重定向我收到错误:
ERR_TOO_MANY_REDIRECTS, because of $route['(:any)'] = 'links/index/$1';
最佳答案
老实说,我不会弄乱路线。相反,我用 uri->segment
抓取了 url 的一部分给你一个主意
//example
//linksid
$links_id = intval($this->uri->segment(3, 0));
所以 http://www.mydomain.com/mycontroller/go/1会抓取 1 然后我可以从那里重定向...
关于php - CodeIgniter 内部重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21466475/