I want to redirect my '/' uri to a given controller's action. I used to do it via the following code in UrlMappings.groovy
:
"/"(action: "highlights", controller: "project")
However, this does not rewrite the url in the browser. It redirects to the correct controller's action, but the browser's navigation Url is still at myProject/
. I would like it to be updated to the "correct" uri so that reloads, etc. use the "correct" uri.
I tried:
"/"(uri: "/project/highlights")
but I get a status 404 response.
Any suggestions on how I should proceed?
UrlMappings is only for how to map the url to your controller.action. It won't do any redirect. If you want to do url redirect, you probably need to setup a http server like apache in front of your application server or the easier way is to just setup a controller.action to do the redirect manually.
"/"(action: "redirect", controller: "project")
In the project
controller, and redirect
action, just redirect the user to your highlights
action.