php - 如何在 htaccess 重写规则中添加分页
问题描述
我正在寻找添加分页htaccess
。
可见网址:
example.com/test/page2
到:
example.com/test/pagination.php?page=2
提前致谢。
解决方案
基本上,您只需要捕获页码,然后将其回收到格式正确的 URL 中。
RewriteRule ^test/(\d+)/*$ /test/pagination.php?page=$1 [L]
RewriteRule : Type of action
^test/(\d+)/*$ : Regex to run against URL
/test/pagination.php?page=$1 : Replacement URL
[L] : Flags; L == Last
例子:
example.com/test/5 >>> example.com/pagination?page=5
推荐阅读
- powershell - 使用 ARM 或 PowerShell 在 AppService 中启用 .NET Core 集合
- java - 片段内的按钮与下一个片段的按钮重叠
- python - 如何使用单个 API 在 django/DRF 中为整个数据库创建搜索功能?
- xamarin.forms - 如何延迟两个信号之一但在必要时丢弃它?
- react-native - 如何在 API 中显示产品名称?
- debugging - Clojure:捕获函数 arg 的运行时值,以在 REPL 中使用
- python - 检测位置数据中的 GPS 峰值
- javascript - 在 .then 中添加 await
- html - 如何设置样式:在没有 javascript 的情况下提交表单后无效
- machine-learning - 针对不同用户的文本选择/个性化