Skip to main content

URL rewriting - Add www in front of url

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
AdemC
Offline
Joined: 2011-10-16

Is there any solution To add a 'www' when user requast site by typing mywebapp.net?

I'am deploying a web application and want to know how i can rewrite url for example

mywebapp.net to https://www.mywebapp.net.

I've set the in web.xml the transport guarantee as confidential and installed a certificate which is valid for www.mywebapp.net, but if someone requests mywebapp.net, the browser says that the certificate is not valid. So I want to redirect all incoming requests on mywebapp.net to https://www.mywebapp.net.

I think thats also enough to redirecting to http://www.mywebapp.net, because the GlassFish container, redirects to the https adress automatically due to the transport guarantee.

Any solution?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
AdemC
Offline
Joined: 2011-10-16

With so many answers ;) I suspect, that there is no easy way to do this. Is it possible to change setting in virtual-server or to code a Servlet Filter and redirect requests to the URL with the www in front. But I think this could be problematic, because of scoped variables??