I am developing a simple cms for an online health magazine using JSP,Tomcat and urlrewritefilter for url rewriting.
I am migrating content from wordpress and should keep the permalinks on the site.
Permalinks looks like below with only letters and numbers.
http://www.example.com/post-or-category-name-with-letters-or-1234/
I want to rewrite my url in my jsp application so that I can have urls like above.
Rewrite Rule should work as follows.
http://www.example.com/post/?pid=1234&name=post-name
http://www.example.com/category/?cid=1234&slug=category-slug
into
http://www.example.com/post-name/
http://www.example.com/category-slug/
And of course vice versa.
How can I have a wordpress-like permalink structure using urlrewritefilter? Do I need to write a Servlet for getting the id of name or slug from DB?
Anybody has an idea how to do that or done it before?
I’ve already done a JavaServer Faces CMS with custom URL for posts and categories. I’ve used basically
javax.servlet.Filter
andjavax.faces.application.ViewHandler
. Since you are in straight JSP you won’t needjavax.faces.application.ViewHandler
.How I declared my filter :
Basic Filter implementation :
I think your answer lies into :
How to rewrite URL in Tomcat 6
Is there a url rewriting engine for Tomcat/Java?