URLs in Tapestry 5 are case-insensitive, meaning you can type http://www.mYsItE.com/iNDEX and it will load http://www.mysite.com/index. The address bar will display the domain name in lower-case but preserve the capitalization you used for pages (e.g. the above example will appear as http://www.mysite.com/iNDEX in the address bar after the page loads)

For SEO purposes we are looking to have our website 301 redirect any mixed-case URL to all-lowercase - converting the entire URL to lowercase, not just the domain. Is there a way to configure Tap5 to 301-redirect mixed-case URLs to lowercase?

(I hope this question isn't too broad. Forgive me if so.)

有帮助吗?

解决方案

You could contribute a HttpServletRequestFilter to the HttpServletRequestHandler or you could contribute a RequestFilter to the RequestHandler. The preferred approach is a RequestFilter.

Make sure you order your filter contribution before:* so that it executes before the rest of the request processing

eg MyAppModule.java

public static void contributeRequestHandler(OrderedConfiguration<RequestFilter> config) {
   config.addInstance(MyRequestFilter.class, "before:*");
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top