I am trying to setup my nginx to redirect all the requests from mobile devices to /mobile/$uri i came up with this solution but it doesn't seem to work. Is it a syntax problem or a misunderstanding of the whole redirecting concept.
if ($http_user_agent ~* '(iPhone|iPod|android|blackberry)') {
rewrite ^(.*) http://xxxx.org/mobile/$1 permanent;
}
When i use my android phone i am getting something like xxx.org/mobile/mobile/mobile/mobile....
Any ideas?Any suggestions?
You should use different locations:
btw, http://nginx.org/r/return
Use http://detectmobilebrowsers.com/ It has scripts for all webservers and client/server side languages.