Permanent redirection from url mapping with parameters not working, grails

1k views Asked by At

I am trying to permanently redirect user from one url to another, and passing on the parameters.

Here is my url:

"/$lang/abc/$city/"
(redirect:[controller:'mycontroller', action:'xyz'], permanent:true)

"/$lang/xyz/$city/" (controller:'mycontroller', action:'xyz')

I want the user to be redirected from like:

/en/abc/dubai 

to

/en/xyz/dubai

But it redirects to

/mycontroller/xyz

What could be possible solution? any help is appreciated. thanks

1

There are 1 answers

0
Anshul On

You can do this way

In URLMappings.groovy define url mapping to some controller and action

/$lang/abc/$city/"(controller:"user", action:"redirectAgain")

and in user controller make and action and redirect uri again

def redirectAgain(){
    redirect uri:"/"+params.lang +"/xyz/" +params.city +"/" 
}