Search code examples
eclipsehttp-redirectjettyuricanonical-name

How do I set a canonical uri on jetty and redirect www users to non www address?


This has been bugging me for some time now, I will greatly appreciate the solution.

I am currently using jetty (jetty-7.3.0.v20110202) to host a static site. I intend to host applications written using JRuby there in the future. I picked Jetty in the first place because someone somewhere told me it had a low memory footprint. I am open to suggestions.

I want to redirect users to a canonical address a-la Redirect non www version of domain to www in Jetty

The method outlined above just doesn't work for me and I have no idea why.

I want my canonical address to be http://example.com/ and any visitors to http://www.example.com/ to be SEO friendly redirected.

I just want to use jetty xml files for the configuration.

I say the jetty documentation is lacking, but I'm not a java programmer, so I'm probably wrong.


Solution

  • I managed to fix this, following the guide included in the link included in the question.

    The thing that was not indicated was that it is imperative that you include a virtualhosts section in your site.xml file.

    It is commented out by default in the test.xml file example and most definitely needs to be uncommented to work in your site!