Question

Config.groovy

grails.serverURL = "http://www.changeme.com"

i set my grails url with "http://www.changeme.com"

in this.. when i type changeme.com its shows me a correct page, but when i am trying to login with http://changeme.com its redirecting me to same login page with http://www.changeme.com and when i logged in through this url then its redirecting me to my page..

So how i set always "www" in my URL.. if someone just type changeme.com

Was it helpful?

Solution

You have to create a filter like this..

 class HostFilters {

   def filters = {
    all(controller:'*', action:'*') {
        before = {
            if(request.getHeader("host") =="changeme.com" )
            {
             redirect(url: "http://www.changeme.com")

            }
        }

    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top