[英]Is the url been rewritten? tuckey - urlrewrite
I use http://tuckey.org/urlrewrite/ library 我使用http://tuckey.org/urlrewrite/库
I am trying to detect if the URL of the page has been rewritten or not, 我正在尝试检测页面的URL是否已被重写,
I come up with something like this: 我想出了这样的东西:
if(req.getRequestURL().toString().contains("?")) {
//do stuff
}
But the url of the page that is rewritten is the same as the normal one: 但是重写的页面的URL与普通的URL相同:
request.getRequestURL().append("?").append(request.getQueryString()).toString();
So my question is: how to detect if the URL has been rewritten or not? 所以我的问题是:如何检测URL是否已被重写?
As far as I know, Tuckey doesn't provide any direct way of testing wheter it actually rewrote a URL or not. 据我所知,Tuckey没有提供任何直接的方法来测试它是否实际重写了URL。
I think your best bet is to add an additional request parameter on the rewrite rule and then test for that parameter. 我认为您最好的选择是在重写规则上添加一个额外的请求参数,然后测试该参数。
Something like: 就像是:
<to type="redirect">/some/url?rewritten</to>
and then something like 然后像
boolean rewritten = request.getParameter("rewritten") != null;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.