.htaccess 文件中的 URL 重写
我当前的 .htaccess 有两个问题。下面的脚本可以工作,但有一个限制
RewriteRule ^products/([0-9])$ /products/$1/ [R]
RewriteRule ^products/([0-9])/$ /viewad.php?adid=$1
限制:如果 adid 大于 10。它会失败。我希望它有任何数量仍然存在并且可以工作。我当前的解决方案是每次 id 高于范围时添加此内容。
RewriteRule ^products/([0-9][0-9])$ /products/$1/ [R]
RewriteRule ^products/([0-9][0-9])/$ /viewad.php?adid=$1
有人可以完善或解释如何纠正这一规则以使数字超出范围吗?
问题二。 映射多个 $_GET 变量。
假设我有一个像这样的网址,
http://veepiz.com/africanews.php?app=view&func=viewcategory&categoryid=2&page=1
我会编写什么规则来使其采用这种格式。
http://veepiz.com/africanews/category/2/page/1
或
http://veepiz.com/africanews/2/1
非常感谢您的宝贵时间
I have two problems in my current .htaccess. The script below works but has a limitation
RewriteRule ^products/([0-9])$ /products/$1/ [R]
RewriteRule ^products/([0-9])/$ /viewad.php?adid=$1
Limitation: if adid, is more than 10. it fails. I want it to have whatever number still there and work. my current solution was to add this everytime the id went higher than range.
RewriteRule ^products/([0-9][0-9])$ /products/$1/ [R]
RewriteRule ^products/([0-9][0-9])/$ /viewad.php?adid=$1
Could some one refine or explain how to correct this rule to take numbers out of range.
Problem Two.
Mapping multiple $_GET variables.
say i had a url like this
http://veepiz.com/africanews.php?app=view&func=viewcategory&categoryid=2&page=1
what rule would i write to have it in this format.
http://veepiz.com/africanews/category/2/page/1
or
http://veepiz.com/africanews/2/1
Thanx a lot for your time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第一个问题:
或者更好:
问题二:
First problem:
Or better yet:
Problem Two:
这解决了问题 2(感谢 aularon):
This fixes problem 2 (thanks to aularon):