php - Codeigniter 路由在分页和其他 URL 上发生冲突
问题描述
CodeIgniter 路由在分页和另一个 URL 上发生冲突。实际上,我正在尝试在分页时加载以下 URL。
对于我的帖子,我想加载以下 URL
http://127.0.0.1/Mytredin_codesup/snippets/auto-loader-63152391
但是一次只运行一个 URL。
我正在使用以下路由
$route['snippets/(:any)'] = 'snippets/view/$1';
$route['allsnippets/(:num)'] = 'welcome';
$route['snippets/(:num)'] = 'snippets';
解决方案
您是否希望函数中的页码用于第三次路由?
是的,这就是我在这条路线上想要的
因此,尝试将您的第三个路由规则更改为,
$route['snippets/(:num)'] = 'snippets/index/$1';
和你在snippets
控制器中的功能
function index(page_no){
//your code here
}
编辑:
按此顺序保持您的路由规则。
$route['snippets/(:num)'] = 'snippets/index/$1';
$route['snippets/(:any)'] = 'snippets/view/$1';
$route['allsnippets/(:num)'] = 'welcome';
问题是在此any
之前num
使用any
将接受任何字符,除了/
并且不会进入num
路由。因此,更改路由顺序将起作用。
推荐阅读
- python - Google Cloud Platform Runtimes Common FTL AttributeError 'NoneType' 对象没有属性 'rsplit'
- python - 从 python 生成的独立 *.exe 不可运行
- c++ - 如何从c ++中内置的类中继承数组
- java - bean 类 [com.zaxxer.hikari.HikariConfig] 的无效属性“url”
- c# - C# 中的反射:对属性进行分组并计算其他属性的总和
- maven - Maven 依赖 NoSuchFieldError
- unity3d - 如何使用 Unity2D 获取整个 HTML 代码
- r - 如何改变列但在 R 管道中保留行名?
- c++ - 超出int的取值范围后无限循环
- c++ - C++中字符串引用参数的效率