我使用地图提出了这个解决方案。我遇到的主要问题是超出了对占位符的 1-9 美元限制。
RewriteMap filtermap txt:content/maps/filtermap.txt [NC]
RewriteCond ${filtermap:$6|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^models/([^/]*/[^/]*)/([^/]*/[^/]*)/([^/]*/[^/]*)/([^/]*/[^/]*)/([^/]*/[^/]*)/([^/]*/[^/]*) /models/?${filtermap:$1}&${filtermap:$2}&${filtermap:$3}&${filtermap:$4}&${filtermap:$5}&${filtermap:$6} [NC,L]
RewriteCond ${filtermap:$5|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^models/([^/]*/[^/]*)/([^/]*/[^/]*)/([^/]*/[^/]*)/([^/]*/[^/]*)/([^/]*/[^/]*) /models/?${filtermap:$1}&${filtermap:$2}&${filtermap:$3}&${filtermap:$4}&${filtermap:$5} [NC,L]
RewriteCond ${filtermap:$4|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^models/([^/]*/[^/]*)/([^/]*/[^/]*)/([^/]*/[^/]*)/([^/]*/[^/]*) /models/?${filtermap:$1}&${filtermap:$2}&${filtermap:$3}&${filtermap:$4} [NC,L]
RewriteCond ${filtermap:$3|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^models/([^/]*/[^/]*)/([^/]*/[^/]*)/([^/]*/[^/]*) /models/?${filtermap:$1}&${filtermap:$2}&${filtermap:$3} [NC,L]
RewriteCond ${filtermap:$2|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^models/([^/]*/[^/]*)/([^/]*/[^/]*) /models/?${filtermap:$1}&${filtermap:$2} [NC,L]
RewriteCond ${filtermap:$1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule ^models/([^/]*/[^/]*) /models/?${filtermap:$1} [NC,L]
它不是超级漂亮,但它确实有效。过滤器图如下所示
p1/v1 p1=v1
p2/v2 p2=v2
...
如果你的 p1/v1 组合是无限的,这不是一个理想的解决方案,但我的组合是有限的,所以它很容易管理。