重写规则问题
RewriteRule ^foo-bar-([0-9]+)-([a-z]+)-([a-z-+]+)/$ index.php?a[]=&b=$1&c=$2&d=$3&e=$4&f=$5 [L,NC]
我怎样才能将规则中的最后一个参数设置为不需要,而不添加两行并在第一行中将其删除,然后在第二行中保留......?
因此,规则必须在一行中,但有两个选项可以用于 acees url,例如:
/foo-bar-2-steps/
/foo-bar-2-steps-eq/
RewriteRule ^foo-bar-([0-9]+)-([a-z]+)-([a-z-+]+)/$ index.php?a[]=&b=$1&c=$2&d=$3&e=$4&f=$5 [L,NC]
how could i put the last parameter from rule to not be required without to add two lines and in first one to remove it, then in second to remain..?
so, rule to be in one line but to have two option to acees url like:
/foo-bar-2-steps/
/foo-bar-2-steps-eq/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下之一:
foo-bar-([az]+)(-([az]+))?< /code>
这里,第二个参数是可选的。请注意,这会更改您的数字索引,因为您使用了额外的括号。
One of the following:
foo-bar-([a-z]+)(-([a-z]+))?
Here, the second parameter is optional. Note that this changes your numerical indexes, since you use extra parenthesis.