.htaccess 具有 2 次重写规则
我有 2 个差异字符串:
index.php?abrir=$1&id=$2 index.php?abrir=$1&livro=$2
id= 和 livro= 所以我尝试使用这个:
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&id=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&id=$2&pagina=$3
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&livro=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&livro=$2&pagina=$3
但只有第一个工作...我该如何解决这个问题?谢谢!
I have 2 diff strings:
index.php?abrir=$1&id=$2
index.php?abrir=$1&livro=$2
id= and livro= so I'm trying using this:
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&id=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&id=$2&pagina=$3
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&livro=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?abrir=$1&livro=$2&pagina=$3
But only the first work... How I can resolve this? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
abrir=.. 和 livro=.. 重写规则中的匹配模式是相同的。使用 .htaccess 文件中与当前请求匹配的第一个重写规则。因此,如果您有两个相同的重写规则,则只有 .htaccess 文件中第一个出现的规则才有效。
The matching patterns in your rewrite rules for abrir=.. and livro=.. are identical. The first rewrite rule in a .htaccess file that matches for the current request is used. So if you have two identical rewrite rules only the one that occurs first in your .htaccess file will work.