Class RewriteRule
java.lang.Object
org.apache.catalina.valves.rewrite.RewriteRule
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected booleanThis flag chains the current rule with the next rule (which itself can be chained with the following rule, etc.).protected RewriteCond[]protected booleanThis sets a cookie on the client's browser.protected Stringprotected booleanprotected intprotected Stringprotected Stringprotected ThreadLocal<String>protected booleanprotected Substitutionprotected Stringprotected booleanThis forces a request attribute named VAR to be set to the value VAL, where VAL can contain regexp back references $N and %N which will be expanded.protected ArrayList<ThreadLocal<String>>protected ArrayList<Substitution>protected Stringprotected booleanThis forces the current URL to be forbidden, i.e., it immediately sends back an HTTP response of 403 (FORBIDDEN).protected booleanThis forces the current URL to be gone, i.e., it immediately sends back an HTTP response of 410 (GONE).protected booleanHost.protected booleanStop the rewriting process here and don't apply any more rewriting rules.protected booleanRe-run the rewriting process (starting again with the first rewriting rule).protected booleanThis makes the Pattern case-insensitive, i.e., there is no difference between 'A-Z' and 'a-z' when Pattern is matched against the current URL.protected booleanThis flag keeps mod_rewrite from applying the usual URI escaping rules to the result of a rewrite.protected booleanThis flag forces the rewriting engine to skip a rewriting rule if the current request is an internal sub-request.protected ThreadLocal<Pattern>protected Stringprotected booleanprotected booleanThis flag forces the rewriting engine to append a query string part in the substitution string to the existing one instead of replacing it.protected booleanWhen the requested URI contains a query string, and the target URI does not, the default behavior of RewriteRule is to copy that query string to the target URI.protected booleanPrefix Substitution with http://thishost[:thisport]/ (which makes the new URL a URI) to force an external redirection.protected intprotected intThis flag forces the rewriting engine to skip the next num rules in sequence when the current rule matches.protected Substitutionprotected Stringprotected booleanForce the MIME-type of the target file to be MIME-type.protected Stringprotected booleanAllows skipping the next valve in the Catalina pipeline.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddCondition(RewriteCond condition) voidaddEnvName(String envName) voidaddEnvValue(String envValue) evaluate(CharSequence url, Resolver resolver) Evaluate the rule based on the contextintgetEnvName(int i) getEnvResult(int i) intgetEnvValue(int i) final StringintintgetSkip()booleanisChain()booleanisCookie()booleanbooleanbooleanisEnv()booleanbooleanbooleanisGone()booleanisHost()booleanisLast()booleanisNext()booleanisNocase()booleanbooleanbooleanfinal booleanbooleanbooleanisType()booleanvoidparse(Map<String, RewriteMap> maps) voidsetChain(boolean chain) voidsetConditions(RewriteCond[] conditions) voidsetCookie(boolean cookie) voidsetCookieDomain(String cookieDomain) voidsetCookieHttpOnly(boolean cookieHttpOnly) voidsetCookieLifetime(int cookieLifetime) voidsetCookieName(String cookieName) voidsetCookiePath(String cookiePath) voidsetCookieSecure(boolean cookieSecure) voidsetCookieValue(String cookieValue) voidsetEnv(boolean env) voidsetEscapeBackReferences(boolean escapeBackReferences) final voidsetFlagsString(String flagsString) voidsetForbidden(boolean forbidden) voidsetGone(boolean gone) voidsetHost(boolean host) voidsetLast(boolean last) voidsetNext(boolean next) voidsetNocase(boolean nocase) voidsetNoescape(boolean noescape) voidsetNosubreq(boolean nosubreq) voidsetPatternString(String patternString) voidsetQsappend(boolean qsappend) final voidsetQsdiscard(boolean qsdiscard) voidsetRedirect(boolean redirect) voidsetRedirectCode(int redirectCode) voidsetSkip(int skip) voidsetSubstitution(Substitution substitution) voidsetSubstitutionString(String substitutionString) voidsetType(boolean type) voidsetTypeValue(String typeValue) voidsetValveSkip(boolean valveSkip) toString()String representation.
- 
Field Details- 
conditions
- 
pattern
- 
substitution
- 
patternString
- 
substitutionString
- 
flagsString
- 
positiveprotected boolean positive
- 
chainprotected boolean chainThis flag chains the current rule with the next rule (which itself can be chained with the following rule, etc.). This has the following effect: if a rule matches, then processing continues as usual, i.e., the flag has no effect. If the rule does not match, then all following chained rules are skipped. For instance, use it to remove the ".www" part inside a per-directory rule set when you let an external redirect happen (where the ".www" part should not to occur!).
- 
cookieprotected boolean cookieThis sets a cookie on the client's browser. The cookie's name is specified by NAME and the value is VAL. The domain field is the domain of the cookie, such as '.apache.org',the optional lifetime is the lifetime of the cookie in minutes, and the optional path is the path of the cookie
- 
cookieName
- 
cookieValue
- 
cookieDomain
- 
cookieLifetimeprotected int cookieLifetime
- 
cookiePath
- 
cookieSecureprotected boolean cookieSecure
- 
cookieHttpOnlyprotected boolean cookieHttpOnly
- 
cookieSubstitution
- 
cookieResult
- 
envprotected boolean envThis forces a request attribute named VAR to be set to the value VAL, where VAL can contain regexp back references $N and %N which will be expanded. Multiple env flags are allowed.
- 
envName
- 
envValue
- 
envSubstitution
- 
envResult
- 
forbiddenprotected boolean forbiddenThis forces the current URL to be forbidden, i.e., it immediately sends back an HTTP response of 403 (FORBIDDEN). Use this flag in conjunction with appropriate RewriteConds to conditionally block some URLs.
- 
goneprotected boolean goneThis forces the current URL to be gone, i.e., it immediately sends back an HTTP response of 410 (GONE). Use this flag to mark pages which no longer exist as gone.
- 
hostprotected boolean hostHost. This means this rule and its associated conditions will apply to host, allowing host rewriting (ex: redirecting internally *.foo.com to bar.foo.com).
- 
lastprotected boolean lastStop the rewriting process here and don't apply any more rewriting rules. This corresponds to the Perl last command or the break command from the C language. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules. For example, use it to rewrite the root-path URL ('/') to a real one, e.g., '/e/www/'.
- 
nextprotected boolean nextRe-run the rewriting process (starting again with the first rewriting rule). Here the URL to match is again not the original URL but the URL from the last rewriting rule. This corresponds to the Perl next command or the continue command from the C language. Use this flag to restart the rewriting process, i.e., to immediately go to the top of the loop. But be careful not to create an infinite loop!
- 
nocaseprotected boolean nocaseThis makes the Pattern case-insensitive, i.e., there is no difference between 'A-Z' and 'a-z' when Pattern is matched against the current URL.
- 
noescapeprotected boolean noescapeThis flag keeps mod_rewrite from applying the usual URI escaping rules to the result of a rewrite. Ordinarily, special characters (such as '%', '$', ';', and so on) will be escaped into their hexcode equivalents ('%25', '%24', and '%3B', respectively); this flag prevents this from being done. This allows percent symbols to appear in the output, as in RewriteRule /foo/(.*) /bar?arg=P1\%3d$1 [R,NE] which would turn '/foo/zed' into a safe request for '/bar?arg=P1=zed'.
- 
nosubreqprotected boolean nosubreqThis flag forces the rewriting engine to skip a rewriting rule if the current request is an internal sub-request. For instance, sub-requests occur internally in Apache when mod_include tries to find out information about possible directory default files (index.xxx). On sub-requests it is not always useful and even sometimes causes a failure to if the complete set of rules are applied. Use this flag to exclude some rules. Use the following rule for your decision: whenever you prefix some URLs with CGI-scripts to force them to be processed by the CGI-script, the chance is high that you will run into problems (or even overhead) on sub-requests. In these cases, use this flag.
- 
qsappendprotected boolean qsappendThis flag forces the rewriting engine to append a query string part in the substitution string to the existing one instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule.
- 
qsdiscardprotected boolean qsdiscardWhen the requested URI contains a query string, and the target URI does not, the default behavior of RewriteRule is to copy that query string to the target URI. Using the [QSD] flag causes the query string to be discarded. Using [QSD] and [QSA] together will result in [QSD] taking precedence.
- 
redirectprotected boolean redirectPrefix Substitution with http://thishost[:thisport]/ (which makes the new URL a URI) to force an external redirection. If no code is given an HTTP response of 302 (FOUND, previously MOVED TEMPORARILY) is used. If you want to use other response codes in the range 300-399 just specify them as a number or use one of the following symbolic names: temp (default), permanent, seeother. Use it for rules which should canonicalize the URL and give it back to the client, e.g., translate "/~" into "/u/" or always append a slash to /u/user, etc. Note: When you use this flag, make sure that the substitution field is a valid URL! If not, you are redirecting to an invalid location! And remember that this flag itself only prefixes the URL with http://thishost[:thisport]/, rewriting continues. Usually you also want to stop and do the redirection immediately. To stop the rewriting you also have to provide the 'L' flag.
- 
redirectCodeprotected int redirectCode
- 
skipprotected int skipThis flag forces the rewriting engine to skip the next num rules in sequence when the current rule matches. Use this to make pseudo if-then-else constructs: The last rule of the then-clause becomes skip=N where N is the number of rules in the else-clause. (This is not the same as the 'chain|C' flag!)
- 
typeprotected boolean typeForce the MIME-type of the target file to be MIME-type. For instance, this can be used to setup the content-type based on some conditions. For example, the following snippet allows .php files to be displayed by mod_php if they are called with the .phps extension: RewriteRule ^(.+\.php)s$ $1 [T=application/x-httpd-php-source]
- 
typeValue
- 
valveSkipprotected boolean valveSkipAllows skipping the next valve in the Catalina pipeline.
 
- 
- 
Constructor Details- 
RewriteRulepublic RewriteRule()
 
- 
- 
Method Details- 
parse
- 
addCondition
- 
evaluateEvaluate the rule based on the context- Parameters:
- url- The char sequence
- resolver- Property resolver
- Returns:
- nullif no rewrite took place
 
- 
toStringString representation.
- 
isEscapeBackReferencespublic boolean isEscapeBackReferences()
- 
setEscapeBackReferencespublic void setEscapeBackReferences(boolean escapeBackReferences) 
- 
isChainpublic boolean isChain()
- 
setChainpublic void setChain(boolean chain) 
- 
getConditions
- 
setConditions
- 
isCookiepublic boolean isCookie()
- 
setCookiepublic void setCookie(boolean cookie) 
- 
getCookieName
- 
setCookieName
- 
getCookieValue
- 
setCookieValue
- 
getCookieResult
- 
isEnvpublic boolean isEnv()
- 
getEnvSizepublic int getEnvSize()
- 
setEnvpublic void setEnv(boolean env) 
- 
getEnvName
- 
addEnvName
- 
getEnvValue
- 
addEnvValue
- 
getEnvResult
- 
isForbiddenpublic boolean isForbidden()
- 
setForbiddenpublic void setForbidden(boolean forbidden) 
- 
isGonepublic boolean isGone()
- 
setGonepublic void setGone(boolean gone) 
- 
isLastpublic boolean isLast()
- 
setLastpublic void setLast(boolean last) 
- 
isNextpublic boolean isNext()
- 
setNextpublic void setNext(boolean next) 
- 
isNocasepublic boolean isNocase()
- 
setNocasepublic void setNocase(boolean nocase) 
- 
isNoescapepublic boolean isNoescape()
- 
setNoescapepublic void setNoescape(boolean noescape) 
- 
isNosubreqpublic boolean isNosubreq()
- 
setNosubreqpublic void setNosubreq(boolean nosubreq) 
- 
isQsappendpublic boolean isQsappend()
- 
setQsappendpublic void setQsappend(boolean qsappend) 
- 
isQsdiscardpublic final boolean isQsdiscard()
- 
setQsdiscardpublic final void setQsdiscard(boolean qsdiscard) 
- 
isRedirectpublic boolean isRedirect()
- 
setRedirectpublic void setRedirect(boolean redirect) 
- 
getRedirectCodepublic int getRedirectCode()
- 
setRedirectCodepublic void setRedirectCode(int redirectCode) 
- 
getSkippublic int getSkip()
- 
setSkippublic void setSkip(int skip) 
- 
getSubstitution
- 
setSubstitution
- 
isTypepublic boolean isType()
- 
setTypepublic void setType(boolean type) 
- 
getTypeValue
- 
setTypeValue
- 
getPatternString
- 
setPatternString
- 
getSubstitutionString
- 
setSubstitutionString
- 
getFlagsString
- 
setFlagsString
- 
isHostpublic boolean isHost()
- 
setHostpublic void setHost(boolean host) 
- 
getCookieDomain
- 
setCookieDomain
- 
getCookieLifetimepublic int getCookieLifetime()
- 
setCookieLifetimepublic void setCookieLifetime(int cookieLifetime) 
- 
getCookiePath
- 
setCookiePath
- 
isCookieSecurepublic boolean isCookieSecure()
- 
setCookieSecurepublic void setCookieSecure(boolean cookieSecure) 
- 
isCookieHttpOnlypublic boolean isCookieHttpOnly()
- 
setCookieHttpOnlypublic void setCookieHttpOnly(boolean cookieHttpOnly) 
- 
isValveSkippublic boolean isValveSkip()
- 
setValveSkippublic void setValveSkip(boolean valveSkip) 
 
-