You set the rule $_SERVER['devicetype']
[devicetype] => 1
you do not need: RewriteRule ^ - [E=DEVICE:%{devicetype}]
If you prefer, you can use this:
RewriteCond %{HTTP_USER_AGENT} "iphone|android" [NC] # i put 2 as example RewriteRule ^ - [E=DEVICE:mobile]
This will install $ _SERVER ['DEVICE] on mobile
source share