In my recent grails project, I was working on mobile version of the application and needed to redirect users to the mobile version of our application, if they are accessing the application from any mobile device. I looked at various techniques/codes to detect the mobile device and redirect users to the specific URL.
I encountered the simplest piece of code which worked in my case and thought it worth sharing.
Just put this code in the head section of your webpage and it will redirect it to the specified URL if the device is a mobile browser.
This worked for me.
Hope it helps