-
1. Re: Removing index.seam from the url
sleroux Mar 17, 2008 9:35 AM (in response to romain.dev.easycity.com)Hi,
Seam is
shipped
with the UrlRewrite library which allow ... well ... URL rewriting.UrlRewrite is based on Apache mod_rewrite, so if you ever used that latter it shouldn't be a problem. Anyway, it's not very difficult to use: please see the online doc which provides several examples.
One last word: You could use URL rewrite to rewrite URL of the form http://myhost/myapp/myfile.xhtml?myparam=myvalue to something more user-friendly like http://myhost/myapp/cooluri/myValue. The point here is, since the config is
application based
, the name of your app is still in the rewrote url. I don't know if you can strip that out.Maybe your application server provide a better way of doing it?
Sylvain.
-
2. Re: Removing index.seam from the url
romain.dev.easycity.com Mar 17, 2008 9:50 AM (in response to romain.dev.easycity.com)Hi Sylvain,
Thanks for your help. UrlRewrite is really handy indead !
Do you know how I can use it to get clean url from an UTF-8 String like :
"Hôtel L'éclaireur" --> http://mysite.com/hotel-l-eclaireur
This
article illustrates what I would like to do (php, drupal).Do you know a nice way to do it with urlrewrite and java ?
Best,
-
3. Re: Removing index.seam from the url
sleroux Mar 17, 2008 11:08 AM (in response to romain.dev.easycity.com)I'm not sure to understand.
UrlRewrite is able to transform the URL from the client request to an URL that will be handled by the server.
You could use it to do that:
http://mysite.com/app/hotel-l-eclaireur => http://mysite.com/app/booking/show_info.seam?name=hotel-l-eclaireur
The user see the
clean
url http://mysite.com/app/hotel-l-eclaireur but the server serves http://mysite.com/app/booking/show_info.seam?name=hotel-l-eclaireurIn URL, you're restricted to a subset of US-ASCII. You cannot have an URL of the form http://mysite.com/app/hôtel-l-éclaireur (ok, I'm sure, you know that;).
If you just want to convert an arbitrary string to a clean-url, you will only need the Java equivalent to preg_replace. Take a look at java.util.regex.Pattern and to the Java tutorial on regexp.
Sylvain.
-
4. Re: Removing index.seam from the url
romain.dev.easycity.com Mar 17, 2008 3:32 PM (in response to romain.dev.easycity.com)Thanks Sylvain,
Here is how I'm cleaning up my url using :
private String removeAccents(String text) { return Normalizer.decompose(text, false, 0) .replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); } private String cleanUrl(String text) { String cleanUrl = this.removeAccents(text); cleanUrl = cleanUrl.toLowerCase(); cleanUrl = cleanUrl.replaceAll("[^\\pL0-9_]+", "-"); cleanUrl = cleanUrl.replaceAll("[^-a-z0-9_]+", ""); return cleanUrl; }
Thanks again for your time.
Cheers