My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">

<!--

configuration file for urlRewriteFilter

-->
<!-- todo: move into a unit test -->
<urlrewrite>

<rule>
<name>Test Rule1</name>
<note>A test rule to show a simple redirect.</note>
<from>/test/status/</from>
<to type="redirect">/rewrite-status</to>
</rule>

<rule>
<name>Bild redirect test</name>
<from>logo.gif</from>
<to type="permanent-redirect">http://127.0.0.1:8080/urlrewrite/artifact_type.gif</to>
</rule>



<rule>
<name>Products</name>
<note>Allows users to type product id's into urls.
ID's published in magazine.</note>

<from>/products/*/*/</from>
<set name="categoryId"/>
<set name="usingFilter">yes</set>
<to>/products.jsp</to>
</rule>

<rule>
<from>/chairs/*/</from>
<set type="session" name="chairShopper">true</set>
<to>/products/chairs.jsp</to>
</rule>

<rule enabled="false">
<name>Test Rule disabled</name>
<condition operator="notequal" type="header" name="user-agent">mac</condition>
<condition type="dayofmonth">14</condition>
<condition type="header" name="charset">utf</condition>
<condition type="user-in-role">admin</condition>
<from>/test/disabled/</from>
<to type="redirect">/rewrite-status</to>
</rule>

<rule>
<name>Test Rule with sets</name>
<condition operator="notequal" type="header" name="user-agent">mac</condition>
<from>/test/disabled/</from>
<set name="blah">ass</set>
<set type="response-header" name="cache-control">ass</set>
</rule>

<rule>
<condition operator="notequal" type="header" name="user-agent">mac</condition>
<from>/test-set/([0-9]+)</from>

<set name="num">num</set>

<!--
will run static method specidied (do(req, res) if no method) on class specified
on startup will invoke init(config)
on shutdown will invoke destroy()

can have as many as you want
-->
<run class="org.tuckey.web.filters.urlrewrite.test.TestRunObj"/>

<run class="org.tuckey.web.filters.urlrewrite.test.TestRunObj" method="run"/>

<run class="org.tuckey.web.filters.urlrewrite.test.TestRunObj" method="nonDefaultRun">
<init-param>
<param-name>aParam</param-name>
<param-value>10</param-value>
</init-param>
</run>

<!--
will create new object then run method specified (just constructor if no method) on class specified
const can be blank or Constructor(req,resp)

can have as many as you want
-->
<run class="org.tuckey.web.filters.urlrewrite.test.TestRunObj" method="nonDefaultRun" neweachtime="true"/>

<run class="org.tuckey.web.filters.urlrewrite.test.TestRunObj" method="nonDefaultRun" neweachtime="true">
<init-param>
<param-name>someParam</param-name>
<param-value>10</param-value>
</init-param>
<init-param>
<param-name>someOtherParam</param-name>
<param-value>20</param-value>
</init-param>
</run>

<to>/test-set.jsp</to>
</rule>


<rule>
<from>/content/([a-zA-Z]+)</from>
<set name="contentItem">$1</set>
<run class="org.tuckey.web.filters.urlrewrite.TestServlet" method="doGet"/>
</rule>

<rule>
<condition type="method">POST</condition>
<from>/pref/([a-zA-Z]+)</from>
<run class="org.tuckey.web.filters.urlrewrite.TestServlet" method="doPost"/>
</rule>


<rule>
<from>/test-redirect-301</from>
<to type="permanent-redirect">/is-this-301</to>
</rule>

<rule>
<from>/test-redirect-302</from>
<to type="temporary-redirect">is-this-302</to>
</rule>

<rule>
<!-- note, regexps cannot be entered against this due to limitations in servlet spec -->
<condition type="user-in-role" name="devil"/>
<from>/test-redirect-302</from>
<to encode="true" type="temporary-redirect">is-this-302</to>
</rule>

<rule>
<name>filenamecheck</name>
<condition type="request-filename" operator="isfile"/>
<from>/check-uw-config-exists.txt</from>
<set name="test1">file exists!!!</set>
<to>/test-set.jsp</to>
</rule>

<outbound-rule>
<name>Out test 1</name>
<condition type="user-in-role" name="devil"/>
<from>/page-not-for-devils(0-9)?</from>
<to>/devils-page</to>
</outbound-rule>

<outbound-rule encodefirst="true">
<condition name="user-agent">googlebot.*</condition>
<from>^(.*);jsessionid=.*$</from>
<to>$1</to>
</outbound-rule>

<outbound-rule match-type="wildcard">
<condition name="user-agent">googlebot*</condition>
<from>*;jsessionid=*</from>
<to>$1</to>
</outbound-rule>

<!--

EXAMPLES

Redirect one url
<rule>
<from>/some/old/page.html</from>
<to type="redirect">/very/new/page.html</to>
</rule>

Redirect a directory
<rule>
<from>/some/olddir/(.*)</from>
<to type="redirect">/very/newdir/$1</to>
</rule>

Clean a url
<rule>
<from>/products/([0-9]+)</from>
<to>/products/index.jsp?product_id=$1</to>
</rule>
eg, /products/1234 will be passed on to /products/index.jsp?product_id=1234 without the user noticing.

Browser detection
<rule>
<condition name="user-agent">Mozilla/[1-4]</condition>
<from>/some/page.html</from>
<to>/some/page-for-old-browsers.html</to>
</rule>
eg, will pass the request for /some/page.html on to /some/page-for-old-browsers.html only for older
browsers whose user agent srtings match Mozilla/1, Mozilla/2, Mozilla/3 or Mozilla/4.

-->


</urlrewrite>

Change log

r319 by tuckey on Oct 26, 2011   Diff
Updated URL to include www
Go to: 
Sign in to write a code review

Older revisions

r287 by tuckey on Jul 28, 2010   Diff
file and dir existence checking
r205 by tuckey on Aug 18, 2008   Diff
moved to Test run objs enable
container testing properly
r199 by tuckey on Aug 14, 2008   Diff
added todos
All revisions of this file

File info

Size: 6439 bytes, 203 lines
Powered by Google Project Hosting