[opencms-dev] url mapping question

Roman Uhlig Maxity.de roman.uhlig at maxity.de
Thu Apr 1 16:45:42 CEST 2010


We had the same issue regarding SEO a while ago, but couldn't find any
useful solution within OpenCms. So we did it this way:
 
We built a server related repository of OpenCms paths mapped to SEO
URL's. This could be just a simple DB table with 2 columns or anything
similar.
 
In the OpenCms 404 handler (/system/handler/handle404.html), we check
this respository (cached into a static map) for an existing mapping like
this:


Integer status = cms.getStatusCode();
if (status != null) {
	cms.setStatus(status.intValue());
	if (status.intValue() == 404) {
		String targetpath = [get OpenCms path for SEO URL from
repository cache];

		if (targetpath.length() > 0) {
			response.setStatus(200);
			
			// do some URI-formatting here, get request
parameters, finally do a cms.include(...) of the targetpath

			return;
		}
	}
}


On the other side, when creating the sitemaps for the search engines
during the automatic nightly build, we check it the other way around and
put the SEO URL's inside the sitemap if there is an existing mapping to
an OpenCms path.

Well, you get the idea. ;)

This approach is limited in it's use, but up to now it does fine for us.

Roman



More information about the opencms-dev mailing list