Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Using nice URL that describe the content of the site will not only improve your ranking but also look more appealling to the users on a SERP (search engine result page). In our case a common URL looks like that:

http://isport.eu/en/premier-league/liverpool-fc/news-19-2008-0.htmlImage Removed

where /en is the language, /premier-league is the currently selected league, /liverpool-fc is the club the page is about, /news are on the page, 19-2008 is the week and 0 is the current page.

...

Code Block
protected WebResponse newWebResponse(final WebRequest webRequest, final HttpServletResponse httpServletResponse){ 
    return new ServletWebResponse((ServletWebRequest)webRequest, httpServletResponse) {

      @Override
      public String encodeURL(CharSequence url) {
          return isRobot(webRequest) ? url.toString() : super.encodeURL(url);
      }
	  
      @Override
      public String encodeRedirectURL(CharSequence url) {
          return isRobot(webRequest) ? url.toString() : super.encodeRedirectURL(url);
      }

      private boolean isRobot(WebRequest request) {
          final String agent = webRequest.getHeader("User-Agent");
          return isAgent(agent) ? url : super.encodeURL(url)/* use 'agent' to decide whether this is a bot */;
      } 
  };
}
Wicket 1.4
Code Block
@Override
protected WebResponse newWebResponse(final HttpServletResponse servletResponse) {
	return new BufferedWebResponse(servletResponse) {
		@Override
		public CharSequence encodeURL(final CharSequence url) {
			final String agent = ((WebRequest) RequestCycle.get().getRequest()).getHttpServletRequest().getHeader("User-Agent");

			return isAgent(agent) ? url : super.encodeURL(url);
		}
	};
}

...