dobbs 01/08/14 17:56:30
Added: xdocs/howto url-rewriting-howto.xml
docs/howto url-rewriting-howto.html
Log:
adding HOWTO for url rewriting
Revision Changes Path
1.1 jakarta-turbine/xdocs/howto/url-rewriting-howto.xml
Index: url-rewriting-howto.xml
===================================================================
<?xml version="1.0"?>
<document>
<properties>
<title>URL Rewriting Howto</title>
<author email="">Gareth Coltman</author>
</properties>
<body>
<section name="Scenario and Overview">
<p>
Unaltered Turbine URLs look like this:
<code>http://www.foo.com:8080/CONTEXT/servlet/MAPPING/template/Foo.vm</code>.<br/>
But you want shorter URLs, or you don't like exposing the use of
servlets in the URL. Maybe this url would suit you better:
<code>http://www.foo.com:8080/po/s/la/template/Foo.vm</code>
</p>
<p>
The bulk of the url is defined by the servlet api and is outside of the
control of Turbine:
<pre>
http://www.foo.com/CONTEXT/servlet/MAPPING/template/Foo.vm
[ servlet api defined ][ turbine ]</pre>
This HOWTO describes how you can control the servlet part of the url
in Tomcat. For other servlet environments you'll have to consult
their documentation.
</p>
<p>
Three parts of the url will be addresed:
<ol>
<li>the web application context (CONTEXT in the example above),</li>
<li>the servlet prefix (servlet),</li>
<li>and the servlet mapping (MAPPING).</li>
</ol>
</p>
</section>
<section name="The Context">
<p>
You need to register the context with Tomcat. If you have given your
application a short name like 'po' and placed it correctly in the
webapps directory, then you won't need to do anything special. Tomcat
will find the directory, and add a context. If you have a long
application name like 'mywonderfulapp', add the following lines to
Tomcat's server.xml file (in the TDK you'll find this here:
<code>tdk/conf/server.xml</code>):
</p>
<source><![CDATA[
<Context
path="/po"
docBase="webapps/mywonderfulapp"
reloadable="true"
debug="0"
trusted="false" >
</Context>
]]></source>
<p>
Everthing after the docBase= line is obviously up to you. This tells
Tomcat to add a context named 'po' with the docbase of your
application.
</p>
</section>
<section name="The Servlet Prefix">
<p>
Modifying the servlet prefix also requires editing Tomcat's server.xml
file. Tomcat will use this prefix to determine if a given request is
for a servlet. Edit the following lines:
</p>
<source><![CDATA[
<RequestInterceptor
className="org.apache.tomcat.request.InvokerInterceptor"
debug="0" prefix="/s/" />
]]></source>
<p>
With this modification, Tomcat recognize requests containing /s/ in
the url as a servlet request and will look for the servlet in the
web.xml descriptor.
</p>
</section>
<section name="The Servlet Name">
<p>
This is defined in web.xml (which you will find here:
<code>webapps/WEB-INF/web.xml</code>). This is automatically given
the name of your application in Turbine. To change it, simply edit the
web.xml file as follows:
</p>
<source><![CDATA[
<servlet-name>
la
</servlet-name>
]]></source>
<p>
<strong>If you are using Tomcat standalone, then you are done and your url is
now <code>http://servername:port:/po/s/la</code></strong>
</p>
</section>
<section name="If you are running Apache and mod_jk">
<p>
... you will need to change your mod_jk.conf file to include the following:
</p>
<source><![CDATA[
#########################################################
# Auto configuration for the /po context starts.
#########################################################
#
# Make Apache aware of the location of the context
#
Alias /po "serverroot/webapps/mywonderfulapp"
<Directory "serverroot/webapps/mywonderfulapp">
Options Indexes FollowSymLinks
</Directory>
#
# Mount all JSP files and the /servlet/ uri to Tomcat
#
JkMount /po/s/* ajp12
JkMount /po/*.jsp ajp12
#
# Prohibit users from directly accessing WEB-INF
#
<Location "/mywonderfulapp/WEB-INF/">
AllowOverride None
deny from all
</Location>
#
# Prohibit users from directly accessing META-INF
#
<Location "/mywonderfulapp/META-INF/">
AllowOverride None
deny from all
</Location>
#######################################################
# Auto configuration for the /po context ends.
#######################################################
]]></source>
<p>
document created August 14, 2001
</p>
</section>
</body>
</document>
1.1 jakarta-turbine/docs/howto/url-rewriting-howto.html
Index: url-rewriting-howto.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<!-- Content Stylesheet for Site -->
<!-- start the processing -->
<!-- ====================================================================== -->
<!-- Main Page Section -->
<!-- ====================================================================== -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<meta name="author"
value="Gareth Coltman">
<meta name="email" value="">
<title>Turbine - URL Rewriting Howto</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#525D76">
<table border="0" width="100%" cellspacing="0">
<!-- TOP IMAGE -->
<tr>
<td align="left">
<a href="http://jakarta.apache.org"><img
src="http://jakarta.apache.org/images/jakarta-logo.gif" border="0"/></a>
</td>
<td align="right">
<a href="http://jakarta.apache.org/turbine/"><img src="../images/logo.gif"
alt="Turbine" border="0"/></a>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="4">
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr>
<!-- LEFT SIDE NAVIGATION -->
<td width="20%" valign="top" nowrap="true">
<p><strong>Essentials</strong></p>
<ul>
<li> <a href="../index.html">Overview</a>
</li>
<li> <a href="../features.html">Features</a>
</li>
<li> <a href="../fsd.html">Specification</a>
</li>
<li> <a href="../getting-started.html">Getting Started</a>
</li>
<li> <a href="../further-reading.html">Further Reading</a>
</li>
</ul>
<p><strong>Get Involved</strong></p>
<ul>
<li> <a href="../contributors.html">Contributors</a>
</li>
<li> <a
href="http://jakarta.apache.org/site/cvsindex.html">CVS Repos</a>
</li>
<li> <a href="../faq.html">FAQ</a>
</li>
<li> <a
href="http://jakarta.apache.org/site/mail.html">Mailing Lists</a>
</li>
<li> <a href="../powered.html">Powered by Turbine</a>
</li>
<li> <a href="../license.html">License</a>
</li>
<li> <a href="../issue-tracking.html">Issue Tracking</a>
</li>
</ul>
<p><strong>Documentation</strong></p>
<ul>
<li> <a href="../turbine-documentation-project.html">Turbine
Documentation</a>
</li>
<li> <a href="../turbine-schema.html">Core Schema</a>
</li>
<li> <a href="../j2ee-integration.html">J2EE Integration</a>
</li>
<li> <a href="../model2+1.html">Model 2+1</a>
</li>
<li> <a href="../pullmodel.html">Pull MVC Model</a>
</li>
<li> <a href="../comma-dot-slash.html">Comma Dot Slash</a>
</li>
<li> <a href="../services.html">Services</a>
</li>
</ul>
<p><strong>Howto Guides</strong></p>
<ul>
<li> <a href="../howto/action-event-howto.html">Action Events
Howto</a>
</li>
<li> <a href="../howto/criteria-howto.html">Criteria Howto</a>
</li>
<li> <a href="../howto/jboss-howto.html">JBoss Howto</a>
</li>
<li> <a href="../howto/jsp-howto.html">JSP Howto</a>
</li>
<li> <a href="../howto/mssql-howto.html">MS SQL Server
Howto</a>
</li>
<li> <a href="../howto/oracle-howto.html">Oracle 8i Howto</a>
</li>
<li> <a href="../howto/peers-howto.html">Peers Howto</a>
</li>
<li> <a href="../howto/postgres-howto.html">Postgres Howto</a>
</li>
<li> <a href="../howto/python-howto.html">Python Howto</a>
</li>
<li> <a href="../howto/security-howto.html">Security Howto</a>
</li>
<li> <a href="../howto/sybase-howto.html">Sybase Howto</a>
</li>
<li> <a href="../howto/tdk-howto.html">TDK Howto</a>
</li>
<li> <a href="../howto/torque-howto.html">Torque Howto</a>
</li>
<li> <a href="../howto/torque-schema-ref.html">Torque Schema
Ref</a>
</li>
<li> <a href="../howto/velocity-site-howto.html">Velocity
Site Howto</a>
</li>
<li> <a href="../howto/context-howto.html">Velocity Context
Howto</a>
</li>
<li> <a href="../howto/webmacro-site-howto.html">Webmacro
Site Howto</a>
</li>
</ul>
<p><strong>Development</strong></p>
<ul>
<li> <a href="../active-developers.html">Active Developers</a>
</li>
<li> <a href="../changes.html">Changes</a>
</li>
<li> <a href="../code-standards.html">Coding Specification</a>
</li>
<li> <a href="../branches.html">CVS Branches</a>
</li>
<li> <a href="../db-adapters.html">DB Adapters</a>
</li>
<li> <a href="../deprecation.html">Deprecation Rules</a>
</li>
<li> <a href="../project-map.html">Project Map</a>
</li>
<li> <a href="../proposals.html">Proposals</a>
</li>
<li> <a href="../todo.html">Todo</a>
</li>
</ul>
</td>
<td width="80%" align="left" valign="top">
<table
border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Scenario and Overview"><strong>Scenario and Overview</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Unaltered Turbine URLs look like this:
<code>http://www.foo.com:8080/CONTEXT/servlet/MAPPING/template/Foo.vm</code>.<br />
But you want shorter URLs, or you don't like exposing the use of
servlets in the URL. Maybe this url would suit you better:
<code>http://www.foo.com:8080/po/s/la/template/Foo.vm</code>
</p>
<p>
The bulk of the url is defined by the servlet api and is outside of the
control of Turbine:
<pre>
http://www.foo.com/CONTEXT/servlet/MAPPING/template/Foo.vm
[ servlet api defined ][ turbine ]</pre>
This HOWTO describes how you can control the servlet part of the url
in Tomcat. For other servlet environments you'll have to consult
their documentation.
</p>
<p>
Three parts of the url will be addresed:
<ol>
<li>the web application context (CONTEXT in the example above),</li>
<li>the servlet prefix (servlet),</li>
<li>and the servlet mapping (MAPPING).</li>
</ol>
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br/></td></tr>
</table>
<table border="0" cellspacing="0"
cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="The Context"><strong>The Context</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
You need to register the context with Tomcat. If you have given your
application a short name like 'po' and placed it correctly in the
webapps directory, then you won't need to do anything special. Tomcat
will find the directory, and add a context. If you have a long
application name like 'mywonderfulapp', add the following lines to
Tomcat's server.xml file (in the TDK you'll find this here:
<code>tdk/conf/server.xml</code>):
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
<Context
path="/po"
docBase="webapps/mywonderfulapp"
reloadable="true"
debug="0"
trusted="false" >
</Context>
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
Everthing after the docBase= line is obviously up to you. This tells
Tomcat to add a context named 'po' with the docbase of your
application.
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br/></td></tr>
</table>
<table border="0" cellspacing="0"
cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="The Servlet Prefix"><strong>The Servlet Prefix</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Modifying the servlet prefix also requires editing Tomcat's server.xml
file. Tomcat will use this prefix to determine if a given request is
for a servlet. Edit the following lines:
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
<RequestInterceptor
className="org.apache.tomcat.request.InvokerInterceptor"
debug="0" prefix="/s/" />
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
With this modification, Tomcat recognize requests containing /s/ in
the url as a servlet request and will look for the servlet in the
web.xml descriptor.
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br/></td></tr>
</table>
<table border="0" cellspacing="0"
cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="The Servlet Name"><strong>The Servlet Name</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
This is defined in web.xml (which you will find here:
<code>webapps/WEB-INF/web.xml</code>). This is automatically given
the name of your application in Turbine. To change it, simply edit the
web.xml file as follows:
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
<servlet-name>
la
</servlet-name>
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
<strong>If you are using Tomcat standalone, then you are done and your url is
now <code>http://servername:port:/po/s/la</code></strong>
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br/></td></tr>
</table>
<table border="0" cellspacing="0"
cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="If you are running Apache and mod_jk"><strong>If you are running
Apache and mod_jk</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
... you will need to change your mod_jk.conf file to include the following:
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
#########################################################
# Auto configuration for the /po context starts.
#########################################################
#
# Make Apache aware of the location of the context
#
Alias /po "serverroot/webapps/mywonderfulapp"
<Directory "serverroot/webapps/mywonderfulapp">
Options Indexes FollowSymLinks
</Directory>
#
# Mount all JSP files and the /servlet/ uri to Tomcat
#
JkMount /po/s/* ajp12
JkMount /po/*.jsp ajp12
#
# Prohibit users from directly accessing WEB-INF
#
<Location "/mywonderfulapp/WEB-INF/">
AllowOverride None
deny from all
</Location>
#
# Prohibit users from directly accessing META-INF
#
<Location "/mywonderfulapp/META-INF/">
AllowOverride None
deny from all
</Location>
#######################################################
# Auto configuration for the /po context ends.
#######################################################
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
document created August 14, 2001
</p>
</blockquote>
</p>
</td></tr>
<tr><td><br/></td></tr>
</table>
</td>
</tr>
<!-- FOOTER -->
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
Copyright © 1999-2001, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</body>
</html>
<!-- end the processing -->
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]