![]() |
| |||||||||||||||||||||
| Resin 3.1 Documentation Tutorials Changes Overview Installation Configuration Quercus SOA/IoC JSP Servlets and Filters Admin (JMX) EJB Amber Security Performance Hessian XML and XSLT Third-party Troubleshooting/FAQ tags Common Tasks Relax Schema howto Config FAQ Scrapbook DB Scrapbook env tags <resin> <cluster> <server> port tags <host> <web-app> <database> session tags rewrite tags service tags log el variables el control |
Resin's <rewrite-dispatch> tag allows configuration for URL aliasing, rewriting, dispatching, and redirection. <dispatch> child of rewrite-dispatch <dispatch> matches the current URL, passing the request to the normal servlet evaluation. <dispatch> is often used to specify URLs which should be handled normally before a more general pattern which modifies the URL. For example, the following pattern uses <dispatch> to handle images and *.php files normally, but forward all other requests to /index.php. <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>
<forbidden> child of rewrite-dispatch <forbidden> sents a 403 forbidden message to the browser for a matching URL. <web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <forbidden regexp="^/protected"/> </rewrite-dispatch> </web-app>
<forward> child of rewrite-dispatch <forward> rewrites the current URL, forwarding it to the target using the servlet forward() call. Because <forward> is internal, it will have better performance than a <redirect> when the target URL is on the same server, the browser will not know that the underlying resource has moved. <web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <forward regexp="^/old" target="/new"/> </rewrite-dispatch> </web-app>
<gone> child of rewrite-dispatch <gone> sents a 410 gone response to the browser for a matching URL. <web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <gone regexp="^/protected"/> </rewrite-dispatch> </web-app>
<load-balance> child of rewrite-dispatch <load-balance> forwards requests from a web-tier server to a cluster of app-tier servers for load-balancing. Load balancing provides scalability by splitting load among many application servers and increases reliability by avoiding servers which are upgrading or restarting. In the following example, the web-tier load-balances all traffic to a cluster of backend application servers. Because the web-tier has a proxy cache, static pages and cached pages will be served directory from the web-tier. <load-balance> requires Resin Professional.
<resin xmlns="http://caucho.com/ns/resin">
<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>
<cluster id="app-tier">
<server id="app-a" address="192.168.3.1">
<server id="app-b" address="192.168.3.2">
...
</cluster>
</resin>
<moved-permanently> child of rewrite-dispatch <moved-permanently> sends a HTTP 301 moved permanently response to the browser, indicating that the resource has moved.
<web-app xmlns="http://caucho.com/ns/resin">
<rewrite-dispatch>
<moved-permanently regexp="^/(foo)" target="http://$1.bar.com"/>
</rewrite-dispatch>
</web-app>
<not-found> child of rewrite-dispatch <not-found> sents a 404 not found to the browser for a matching URL. <web-app xmlns="http://caucho.com/ns/resin"> <rewrite-dispatch> <not-found regexp="^/protected"/> </rewrite-dispatch> </web-app>
<real-path> child of rewrite-real-path <real-path> maps a URL to a filesystem path inside a <rewrite-real-path tag. The source path is a URL, the target path is a real filesystem path.
<web-app xmlns="http://caucho.com/ns/resin">
<rewrite-real-path>
<real-path regexp="^/images" real-path="/usr/local/share/images"/>
</rewrite-real-path>
<redirect> child of rewrite-dispatch <redirect> sends a HTTP 302 redirect response to the browser, indicating that the resource has moved.
<web-app xmlns="http://caucho.com/ns/resin">
<rewrite-dispatch>
<redirect regexp="^/(foo)" target="http://$1.bar.com"/>
</rewrite-dispatch>
</web-app>
<rewrite> child of rewrite-dispatch <rewrite> rewrites the current URL, continuing processing of the <rewrite-dispatch> tags. <rewrite> can be used as an intermediate rewriting stage for more complicated patterns.
<rewrite-real-path> child of web-app <rewrite-real-path> configures an alias for the getRealPath() call, i.e. an enhancement to the <path-mapping> tag. The source path is a URL, the target path is a real filesystem path.
<web-app xmlns="http://caucho.com/ns/resin">
<rewrite-real-path>
<real-path regexp="^/images" real-path="/usr/local/share/images"/>
</rewrite-real-path>
<rewrite-dispatch> child of web-app, host <rewrite-dispatch> evaluates the child tags in order. The first matching tag dispatches the request. If no children match, the request uses the standard servlet handling. The child tags rewrite and dispatch based on regexp patterns. <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>
| |||||||||||||||||||||