您的位置:首页 > Web前端

urlrewriteFilter condition----reference

2013-12-23 17:20 316 查看
src:http://tuckey.org/urlrewrite/manual/2.6/

<condition> element

An element that lets you choose conditions for the rule. Note, all conditions must be met for the rule to be run (unless "next" is set to "or" obvoiusly).

Value can be any Regular Expression (Perl5 style).

AttributePossible ValueExplanation
type
(optional)
header (default)If used, the header name must be specified in the "name" attribute.
methodThe method of the request. GET, POST, HEAD etc.
portThe port that the web application server is running on.
timeCurrent time at the server (this will be the number of seconds since 00:00:00 1970-01-01 UTC otherwise known as unix
time).

i.e.
(new Date()).getTime()


This can be used for making sure content goes live only at a time you set.
yearCurrent year at the server.

i.e.
(Calendar.getInstance()).get(Calendar.YEAR)

monthMonth at the server. January is 0

i.e.
(Calendar.getInstance()).get(Calendar.MONTH)

dayofmonthDay of the month at the server. March first is 1

i.e.
(Calendar.getInstance()).get(Calendar.DAY_OF_MONTH)

dayofweekDay of the week at the server. Saturday is 1, Sunday is 7

i.e.
(Calendar.getInstance()).get(Calendar.DAY_OF_WEEK)

ampmAM or PM time at the server.

i.e.
(Calendar.getInstance()).get(Calendar.AM_PM)

hourofdayThe hour of the day (24 hour clock) at the server. 10pm is 22

i.e.
(Calendar.getInstance()).get(Calendar.HOUR_OF_DAY)

minuteThe minute field of the current time at the server.

i.e.
(Calendar.getInstance()).get(Calendar.MINUTE)

secondThe second field of the current time at the server.

i.e.
(Calendar.getInstance()).get(Calendar.SECOND)

millisecondThe millisecond field of the current time at the server.

i.e.
(Calendar.getInstance()).get(Calendar.MILLISECOND)

attributeWill check the value of a request attribute (don't confuse this with parameter!),
name
must be set when
using this type.

i.e.
request.getAttribute([name])

auth-typeWill check the value of a request attribute (don't confuse this with parameter!)

i.e.
request.getAuthType()

character-encodingThe character encoding of the imcoming request.

i.e.
request.getCharacterEncoding()

content-lengthThe length of the imcoming request (can be useful if you want to deny large requests).

i.e.
request.getContentLength()

content-typeThe type of the imcoming request. (this is probably not that useful)

i.e.
request.getContentType()

context-pathThe context path of the imcoming request.

i.e.
request.getContextPath()

cookieThe value of a cookie, note,
name
must be specified to use this

i.e.
request.getCookies()
the find we the one with [name] specified and check the value.
parameterA tidier way of checking request parameters than looking for them in the query string. This will check for the
parameter in GET or POST, note,
name
must be specified.

i.e.
request.getParameter([name])

path-infoi.e.
request.getPathInfo()

path-translatedi.e.
request.getPathTranslated()

protocolThe protocol used to make the request, e.g. HTTP/1.1

i.e.
request.getProtocol()

query-stringThe query string used to make the request (if any), e.g. id=2345&name=bob

i.e.
request.getQueryString()

remote-addrThe IP address of the host making the request, e.g. 123.123.123.12

i.e.
request.getRemoteAddr()

remote-hostThe host name of the host making the request, e.g. 123qw-dsl.att.com (note,
this will only work if your app server is configured to lookup host names, most aren't).

i.e.
request.getRemoteHost()

remote-userThe login of the user making this request, if the user has been authenticated, e.g. bobt

i.e.
request.getRemoteUser()

requested-session-idReturns the session ID specified by the client, e.g. 2344asd234sada4

i.e.
request.getRequestedSessionId()

request-uriReturns the part of this request's URL from the protocol name up to the query
string in the first line of the HTTP request

i.e.
request.getRequestURI()

request-urlReconstructs the URL the client used to make the request. The returned URL
contains a protocol, server name, port number, and server path, but it does not include query string parameters.

i.e.
request.getRequestURL()

session-attribute(note, name must be set)

i.e.
session.getAttribute([name])

session-isnewWeather the session is new or not.

i.e.
session.isNew()

server-nameThe host name of the server to which the request was sent (from the host header not the machine name).

i.e.
request.getServerName()

schemeThe scheme used for the request, e.g. http or https

i.e.
request.getScheme()

user-in-role(Note, the value for this cannot be a regular expression)

i.e.
request.isUserInRole([value])

name
(optional)
(can be anything)If type is header, this specifies the name of the HTTP header used to run the value
against.
next
(optional)
and (default)The next "rule" and this "rule" must match.
orThe next "rule" or this "condition" may match.
operator
(optional)
equal (default)Equals. The operator to be used when the condition is run.
notequalNot equal to. (i.e. request value != condition value). Note, this operator only work with
numeric rule types.
greaterGreater than. (i.e. request value > condition value). Note, this operator only work with
numeric
rule types.
lessLess than. (i.e. request value < condition value). Note, this operator only work with numeric
rule types.
greaterorequalGreater to or equal to. (i.e. request value >= condition value). Note, this operator
only
work with numeric rule types.
lessorequalLess than or equal to. (i.e. request value <= condition value). Note, this operator only
work with numeric rule types.
Examples:

<condition name="user-agent" operator="notequal">Mozilla/[1-4]</condition>

<condition type="user-in-role" operator="notequal">bigboss</condition>

<condition name="host" operator="notequal">www.example.com</condition>

<condition type="method" next="or">PROPFIND</condition>
<condition type="method">PUT</condition>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: