Mod_重写问题
如何使用 mod_rewrite 将以下 URL 示例 1 转换为示例 2?
实施例1
http://www.example.com/cat/index.php?cat=fruit&sub1=apple&sub2=green
实施例2
http://www.example.com/cat/fruit/apple/green/
How can I turn the following URL example 1 to example 2 using mod_rewrite?
Example 1
http://www.example.com/cat/index.php?cat=fruit&sub1=apple&sub2=green
Example 2
http://www.example.com/cat/fruit/apple/green/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用类似这样的内容:
$1
、$2
、$3
和$4
代表四个匹配组(. *)
如果子类别的数量可变,您应该更改策略:
并手动解析
subcat_string
(Python 中的示例):Use something like this:
$1
,$2
,$3
and$4
represent the four matched groups(.*)
If there is a variable number of subcategories, you should change your strategy:
And parse the
subcat_string
manually (example in python):