为什么我必须在 mod 重写 url 中添加未使用的变量?
我的 htaccess 文件有这段代码:
RewriteEngine On
RewriteRule /([^/]+)?$ index.php?page=$1
RewriteRule /([^/]+)/([^/]+)?$ index.php?page=$1&var1=$2
RewriteRule /([^/]+)/([^/]+)/([^/]+)?$ index.php?page=$1&var1=$2&var2=$3
它工作正常,但是当我在 index.php 上打印出 get 数组时,它会忽略第一个变量,所以我必须执行类似 spareslist.com/randomthing/page/var1/var2 的操作
我怎样才能使用它而不需要在其他变量之前有一个随机变量?
I have this code for my htaccess file:
RewriteEngine On
RewriteRule /([^/]+)?$ index.php?page=$1
RewriteRule /([^/]+)/([^/]+)?$ index.php?page=$1&var1=$2
RewriteRule /([^/]+)/([^/]+)/([^/]+)?$ index.php?page=$1&var1=$2&var2=$3
It works fine however when I print out the get array on index.php it ignores the first variable so i have to do something like spareslist.com/randomthing/page/var1/var2
How would I be able to use this without having to have a random variable before the others?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 RewriteRule 中使用 ^ 怎么样?像这样:
What about using the ^ in RewriteRule? Like this: