Hi, I'd like to simplify the URL's to access a Glassfish V3 application by removing file extensions and otherwise shortening URL's.
I've already set my application as the default application, so that there is no need to include the context root in the URL.
I'd like to:
* Remove file extensions
* Shorten the URL to files deep in the folder structure
I'd like to do this using pattern matching rather than on a per file basis (Site is small at the moment but will change frequently and grow).
Some examples of what I'd like to do:
* foo.com/bar.html -> foo.com/bar
* foo.com/folder1/folder2/bar2.html -> foo.com/bar2
Any help would be greatly appreciated. Thanks.
Cheers,
Jin
-
Taken from http://www.sun.com/bigadmin/sundocs/articles/urlrdn.jsp seems like this is what you are looking for.
URL Redirection Within a Domain
You can use the url-prefix element of the redirect_ property to forward a URL to another URL in the same domain.
The following procedure shows how to enable visitors to a web site to type in http://www.mywebsite.com/myproduct1 and be redirected or forwarded to http://www.mywebsite.com/mywarname/products/myproduct1.jsp.
- Log in to the Admin Console of Sun Java System Application Server or GlassFish.
- In the Admin Console, expand the Configurations node.
Expand the server-config node.
Ignore this step if you are running a developer domain (a domain that does not have clustering capability).
Expand HTTP Service.
- Expand Virtual Servers.
- Click server.
- On the Edit Virtual Server page, click the Add Property button.
- In the Name column, type
redirect_1. If you are using Application Server 9.0, type
from=/<context-root>/myproduct1 url-prefix=/mywarname/mypages/products/myproduct1.jspin the Value column.Note - The value of the
<context-root>you provide here needs to match the value of the context root specified in the web.xml or application.xml file.If you are using Application Server 9.1, type
from=/myproduct1 url-prefix=/mywarname/mypages/products/myproduct1.jspin the Value column.
Jin Liew : Thanks for this, but I believe this requires each page to be set up individually - please let me know if this is not the case. I'd like a solution where I can use wildcards to specify multiple redirections (e.g. remove the extensions for all HTML files).Prix : From what i saw you have 2 choices beside the above one: A) use Tuckey's Url Rewrite Filter (http://www.tuckey.org/urlrewrite/) B) or use apache as your front end with mod_rewrite and mod_proxyFrom Prix
0 comments:
Post a Comment