📄 rewrite-tags.xtp
字号:
<document><header> <product>resin</product> <title>URL rewrite tags</title> <version>Resin 3.0</version> <description><p>Resin's <a href="#rewrite-dispatch"><rewrite-dispatch></a> tag allowsconfiguration for URL aliasing, rewriting, dispatching, and redirection.</p><p><a href="#rewrite-real-path"><rewrite-real-path></a> configures an aliasfor files located on the filesystem, allowing for the mapping of a virtual directory.</p> </description></header><body><localtoc/><defun title="<and>"><parents>when, unless</parents><p>Contains one or more conditions and evaluates to true if all of the containedconditions evaluate to true, false if any of the contained conditions does notevaluate to true.</p></defun><defun title="auth-type"><parents>when, unless</parents><p>Evaluates to true if the authorization mechanism used in the request is the given value.The comparison is always case insensitive.</p><p>If the auth-type is not "none", or if the auth-type of the request is not"none", a <code>Cache-Control</code> header containing "<code>private</code>"is added to the response.</p><deftable-childtags><tr><td>auth-type</td> <td>BASIC, CLIENT-CERT, DIGEST, FORM, or NONE</td> <td>required</td></tr><tr><td>send-vary</td> <td>Send a <code>Vary</code> header containing "<code>Cookie</code>" as part of the response</td> <td>true</td></tr></deftable-childtags></defun><defun title="cookie"><parents>when, unless</parents><p>Evaluates to true if the value of a cookie with a given <var/name/> matches a regularexpression <var/regexp/>, false if it does not or if the cookie does not exist.</p><p>The <var/Vary/> header of the response is updated to include "Cookie",which indicates to the browser and any intervening proxy cache that theresponse varies based on the submitted value of cookies.</p><deftable-childtags><tr><td>cookie</td> <td>Name of the cookie</td> <td>required</td></tr><tr><td>regexp</td> <td>The regular expression to match</td> <td>optional</td></tr><tr><td>send-vary</td> <td>Send a <code>Vary</code> header containing "<code>Cookie</code>" as part of the response</td> <td>true</td></tr></deftable-childtags></defun><defun title="disable-at"><p>Cron syntax for specifying a time or times that that the rule should be disabled.In conjunction, <var>enable-at</var> and <var>disable-at</var> provide a means forscheduling the enablement of a rule.</p></defun><defun title="<dispatch>"><parents>rewrite-dispatch, match</parents><p>If <dispatch> matches the current URL, the rest of the items in the enclosingrewrite-dispatch are not considered and the request passes immediately tonormal servlet evaluation. <dispatch> is often used to specify URLswhich should be handled normally before a more general pattern whichmodifies the URL.</p><p>For example, the following pattern uses <dispatch> to handleimages and *.php files normally, but forward's all other requests to/index.php.</p><example title="Mediawiki dispatch in resin-web.xml"><web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <dispatch regexp="\.(php|gif|css|jpg|png)"/> <forward regexp="^" target="/index.php"/> </rewrite-dispatch></web-app></example><deftable-childtags><tr><td><a href="#disable-at">disable-at</a></td> <td>A cron syntax time specification for triggering disablement of the rule</td> <td>none</td></tr><tr><td><a href="#enable-at">enable-at</a></td> <td>A cron syntax time specification for triggering enablement of the rule</td> <td>none</td></tr><tr><td>enabled</td> <td>False to start with the rule initially disabled</td> <td>true</td></tr><tr><td><a href="#name">name</a></td> <td>A name to use for registering a JMX mbean with type=RewriteRule</td> <td>do not register an mbean</td></tr><tr><td>regexp</td> <td>A regexp that must match the <a href="#URL">URL</a></td> <td>optional</td></tr><tr><td><a href="#when">when</a></td> <td>A condition which must evaluate to true</td> <td>optional</td></tr><tr><td><a href="#unless">unless</a></td> <td>A condition which must not evaluate to true</td> <td>optional</td></tr></deftable-childtags></defun><defun title="dispatch-type"><p>The dispatch-type lets you configure rewrite-dispatch for REQUEST,FORWARD, or INCLUDE. By default, the rewrite-dispatch is REQUEST.</p><example title="Example: FORWARD dispatch"><web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <dispatch-type>FORWARD</dispatch-type> <forward regexp="/foo" target="/bar.jsp"/> </rewrite-dispatch></web-app></example></defun><defun title="enable-at"><p>Cron syntax for specifying a time or times that that the rule should be enabled,see <a href="#disable-at"><disable-at/></a>.</p></defun><defun title="enabled"><p>Set's the initial state of the rule, default is true. In conjunction with<a href="#name">name</a>, an initial enabled value of "false" is valuable forrules which are to be turned on and turned off at runtime.</p></defun><defun title="<forbidden>"><parents>rewrite-dispatch, match</parents><p><forbidden> sents a 403 forbidden message to the browserfor a matching URL.</p><example title="Forbidding a directory"><web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <forbidden regexp="^/protected"/> </rewrite-dispatch></web-app></example><deftable-childtags><tr><td><a href="#disable-at">disable-at</a></td> <td>A cron syntax time specification for triggering disablement of the rule</td> <td>none</td></tr><tr><td><a href="#enable-at">enable-at</a></td> <td>A cron syntax time specification for triggering enablement of the rule</td> <td>none</td></tr><tr><td>enabled</td> <td>False to start with the rule initially disabled</td> <td>true</td></tr><tr><td><a href="#name">name</a></td> <td>A name to use for registering a JMX mbean with type=RewriteRule</td> <td>do not register an mbean</td></tr><tr><td>regexp</td> <td>A regexp that must match the <a href="#URL">URL</a></td> <td>optional</td></tr><tr><td><a href="#when">when</a></td> <td>A condition which must evaluate to true</td> <td>optional</td></tr><tr><td><a href="#unless">unless</a></td> <td>A condition which must not evaluate to true</td> <td>optional</td></tr></deftable-childtags></defun><defun title="<forward>"><parents>rewrite-dispatch, match</parents><p><forward> rewrites the current URL, forwarding it to the targetusing the servlet forward() call. Because <forward> is internal,it will have better performance than a <redirect> when the targetURL is on the same server, the browser will not know that theunderlying resource has moved.</p><example title="Forwarding to a new URL"><web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <forward regexp="^/old" target="/new"/> </rewrite-dispatch></web-app></example><deftable-childtags><tr><td><a href="#disable-at">disable-at</a></td> <td>A cron syntax time specification for triggering disablement of the rule</td> <td>none</td></tr><tr><td><a href="#enable-at">enable-at</a></td> <td>A cron syntax time specification for triggering enablement of the rule</td> <td>none</td></tr><tr><td>enabled</td> <td>False to start with the rule initially disabled</td> <td>true</td></tr><tr><td><a href="#name">name</a></td> <td>A name to use for registering a JMX mbean with type=RewriteRule</td> <td>do not register an mbean</td></tr><tr><td>regexp</td> <td>A regexp that must match the <a href="#URL">URL</a></td> <td>optional</td></tr><tr><td>target</td> <td>The target of the the foreward</td> <td>required</td></tr><tr><td><a href="#when">when</a></td> <td>A condition which must evaluate to true</td> <td>optional</td></tr><tr><td><a href="#unless">unless</a></td> <td>A condition which must not evaluate to true</td> <td>optional</td></tr></deftable-childtags></defun><defun title="header"><parents>when, unless</parents><p>Evaluates to true if the value of a header with a given <var/name/> matches a regularexpression <var/regexp/>, false if it does not or if the header does not exist.</p><p>The <var/Vary/> header of the response is updated to include the header namewhich indicates to the browser and any intervening proxy cache that theresponse varies based on the submitted value of the header.</p><deftable-childtags><tr><td>header</td> <td>Name of the header</td> <td>required</td></tr><tr><td>regexp</td> <td>The regular expression to match</td> <td>optional</td></tr><tr><td>send-vary</td> <td>Send a <code>Vary</code> header containing the header name as part of the response</td> <td>true</td></tr></deftable-childtags></defun><defun title="<gone>"><parents>rewrite-dispatch, match</parents><p><gone> sents a 410 gone response to the browserfor a matching URL.</p><example title="Hiding a directory"><web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <gone regexp="^/protected"/> </rewrite-dispatch></web-app></example><deftable-childtags><tr><td><a href="#disable-at">disable-at</a></td> <td>A cron syntax time specification for triggering disablement of the rule</td> <td>none</td></tr><tr><td><a href="#enable-at">enable-at</a></td> <td>A cron syntax time specification for triggering enablement of the rule</td> <td>none</td></tr><tr><td>enabled</td> <td>False to start with the rule initially disabled</td> <td>true</td></tr><tr><td><a href="#name">name</a></td> <td>A name to use for registering a JMX mbean with type=RewriteRule</td> <td>do not register an mbean</td></tr><tr><td>regexp</td> <td>A regexp that must match the <a href="#URL">URL</a></td> <td>optional</td></tr><tr><td><a href="#when">when</a></td> <td>A condition which must evaluate to true</td> <td>optional</td></tr><tr><td><a href="#unless">unless</a></td> <td>A condition which must not evaluate to true</td> <td>optional</td></tr></deftable-childtags></defun><defun title="<import>"><parents>rewrite-dispatch, match</parents><p><import> loads rules from an external xml file.</p><example title="Importing rules from an external file"><web-app xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core"> <rewrite-dispatch> <import path='/WEB-INF/rewrite-maintenance.xml' enabled="false"/> <import path='/WEB-INF/rewrite-rules.xml'/> </rewrite-dispatch></web-app></example><example title="An external file containing rules"><rewrite-dispatch xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core"> <dispatch regexp="\.(css|gif|jpg|pdf|png)"/> <forward regexp=".*" target="/maintenance.html"/></rewrite-dispatch></example><p>Changes to the external file are checked for at a frequency determined by<var>dependency-check-interval</var> or when the <code>update()</code>operation of the mbean is invoked. If an error occurs when loading themodified file, the contents of the old file are used until the errors arecorrected or the server is restarted. The log file will contain details forthe error, and the <code>RedeployError</code> property of the mbean wil contain a description of the error.</p><p>Each <import> registers an mbean of type RewriteImport, with a full a namelike "resin:Host=default,WebApp=/,name=Foo,type=RewriteRule" and an interfaceof <a href="javadoc|com.caucho.management.server.RewriteImportMXBean|"/>.It provides the <code>update()</code>, <code>start()</code> and <code>stop()</code> operations.The <code>update()</code> operations forces an immediate check for modifications to the external file.</p><deftable-childtags><tr><td><a href="#disable-at">disable-at</a></td> <td>A cron syntax time specification for triggering disablement of the rule</td> <td>none</td></tr><tr><td>dependency-check-interval</td> <td>The frequency with which to check the external file for changes</td> <td>The <a href="env-tags.xtp#dependency-check-interval">dependency-check-interval</a> of the environment</td></tr><tr><td><a href="#enable-at">enable-at</a></td> <td>A cron syntax time specification for triggering enablement of the rule</td> <td>none</td></tr><tr><td>enabled</td> <td>False to start with the rule initially disabled</td> <td>true</td></tr><tr><td><a href="#name">name</a></td> <td>A name to use for registering a JMX mbean with type=RewriteImport</td> <td>the value of <var/path/></td></tr><tr><td>optional</td> <td>If false, do not require that the path exists</td> <td>true</td></tr><tr><td>path</td> <td>A path to an external xml file</td> <td>required</td></tr></deftable-childtags></defun><defun title="<load-balance>"><parents>rewrite-dispatch, match</parents><p><load-balance> forwards requests from a <g>web-tier</g> serverto a cluster of <g>app-tier</g> servers for<a href="resin-clustering.xtp">load-balancing</a>. Load balancingprovides scalability by splitting load among many application serversand increases reliability by avoiding servers which are upgrading orrestarting.</p><p>In the following example, the web-tier load-balances all trafficto a cluster of backend application servers. Because the web-tierhas a <a href="proxy-cache.xtp">proxy cache</a>, static pagesand cached pages will be served directory from the web-tier.</p><p><load-balance> requires Resin Professional.</p><example title="Load balancing to an app-tier"><resin xmlns="http://caucho.com/ns/resin"> <cluster id="app-tier"> <server id="app-a" address="192.168.3.1"> <server id="app-b" address="192.168.3.2"> ... </cluster> <cluster id="web-tier"> <server id="web-a" address="192.168.2.1"> <http port="80"/> </server> <cache/> <host id=""> <web-app id="/"> <rewrite-dispatch> <load-balance regexp="" cluster="app-tier"/> </rewrite-dispatch> </web-app> </host></resin></example><deftable-childtags><tr><td>cluster</td> <td>The cluster that gets the matching requests</td> <td>required</td></tr><tr><td><a href="#disable-at">disable-at</a></td> <td>A cron syntax time specification for triggering disablement of the rule</td> <td>none</td></tr><tr><td><a href="#enable-at">enable-at</a></td> <td>A cron syntax time specification for triggering enablement of the rule</td> <td>none</td></tr><tr><td>enabled</td> <td>False to start with the rule initially disabled</td> <td>true</td></tr><tr><td><a href="#name">name</a></td> <td>A name to use for registering a JMX mbean with type=RewriteRule</td> <td>do not register an mbean</td></tr><tr><td>regexp</td> <td>A regexp that must match the <a href="#URL">URL</a></td> <td>optional</td></tr><tr><td>sticky-sessions</td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -