i want to setup in my .htaccess apache file the env var for mobile
i have:
SetEnvIf User-Agent "iPhone" devicetype
SetEnvIf User-Agent "Android" devicetype
RewriteRule ^ - [E=DEVICE:%{devicetype}]
but my $_SERVER['DEVICE'] is always empty. why?
You rule will set the $_SERVER['devicetype']
[devicetype] => 1
you don't 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 set $_SERVER['DEVICE'] to mobile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With