url rewrite in Sun Java Web server 6.1
Friday Jul 04, 2008
First, if you can use web 7.0u3, then please use web 7.0u3 because it has much better rewrite capability in rewrite, e.g.
from its release notes at
http://docs.sun.com/app/docs/doc/820-4848/gduun?a=view
"You can use these new features to define flexible URL rewriting and redirection rules such as those possible with mod_rewrite from the Apache HTTP server. Unlike mod_rewrite, regular expressions and conditional processing in Web Server 7.0 can be used at any stage of request processing, even with third-party plug-ins."
If you cannot use web 7.0u3 because of e.g. other plugins compatibility, then you can still use 6.1SP9 to rewrite in some situations.
e.g. If you like to rewrite such that
http://host.domain:port/abc/en_US/*.* to
http://host.domain:port/en_US/*.*
(Note - no more /abc after the rewrite ).
Then , one possible way is :
<Object name="default">
AuthTrans fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true"
<Client $path =~ "/abc\/">
NameTrans fn="redirect" from="/abc/" url-prefix="http://apple.asia.sun.com:61901/"
</Client>
NameTrans fn="ntrans-j2ee" name="j2ee"
....
then restart web server,
(my LS port is at 61901 , so url-prefix="http://apple.asia.sun.com:61901" above,
you can try something like http://www.something.com/ instead in above)
Then some testings:
0. an original request to
http://apple.asia.sun.com:61901/abc/en_US/banner.html
will result in a redirect request with a Location header,
Location: http://apple.asia.sun.com:61901/en_US/banner.html *** this is a correct rewrite new Location
1. an original request to
http://apple.asia.sun.com:61901/abc/
will result in a redirect request with a Location header,
Location: http://apple.asia.sun.com:61901/ *** this is a correct rewrite new Location
2. an original request to
http://apple.asia.sun.com:61901/abc/test2.jsp
will result in a redirect request with a Location header,
Location: http://apple.asia.sun.com:61901/test2.jsp *** this is a correct rewrite new Location
3. an original request to
http://apple.asia.sun.com:61901/abc/index.html
will result in a redirect request with a Location header,
Location: http://apple.asia.sun.com:61901/index.html *** this is a correct rewrite new Location
4. an original request to
http://apple.asia.sun.com:61901/abc2/banner.html
(Note - we tested /abc2 to make sure it will not over-match!)
will NOT result in a any new redirect request with a Location header as expected.
The response is:
HTTP/1.x 304 Use local copy *** see no redirect (correct and as expected)
Date: Fri, 04 Jul 2008 03:22:19 GMT
Etag: "723-486d95a1"
5. an original request to
http://apple.asia.sun.com:61901/abc.html
(Note - we tested /abc.html to make sure it will not over-match!)
will NOT result in a any new redirect request with a Location header as expected.
The response is:
HTTP/1.x 200 OK *** see no redirect (correct and as expected)
Date: Fri, 04 Jul 2008 03:22:48 GMT
Content-Length: 49
Content-Type: text/html
Last-Modified: Fri, 04 Jul 2008 02:03:30 GMT
Etag: "20-486d84f2"
Tags: client nametrans redirect tag url-prefix










