【发布时间】:2014-06-20 12:20:20
【问题描述】:
我想将用户 ID 与特定应用 ID 相关联,例如:
<user_id> <app_id>
615 1
616 7
617 3
618 3
我的 URI 看起来像:
/<app_id>/<user_id>/...
现在,我希望能够在不影响用户书签的情况下轻松更改应用程序。在我的例子中,我想要两个
/1/615/index.html or /3/615/index.html
担任
/1/615/index.html
通过以下规则,我得到无限循环:
RewriteMap map dbm:user-application.map
RewriteRule ^/([0-9]+)/([0-9]+)/(.*)$ /${map:$2}/$2/$3 [R,L]
...
#other proxy code to forward request to applications
我了解重定向后,Apache 将始终执行相同的规则。 然后我尝试添加一个重写条件来阻止循环,比如
RewriteMap map dbm:user-application.map
RewriteCond %{REQUEST_URI} !^/${map:$2}
RewriteRule ^/([0-9]+)/([0-9]+)/(.*)$ /${map:$2}/$2/$3 [R,L]
如果我正确阅读了我的重写日志,我可以看到变量 !^/${map:$2} 没有在条件模式中被替换,而是“按原样”检查。然后条件总是为真,我仍然得到我的无限循环。
应用程序 ID 与我的地图匹配后立即阻止循环的任何想法?
【问题讨论】:
标签: apache mod-rewrite rewritemap