Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess apache env var not working

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?

like image 995
Trent Miller Avatar asked Feb 12 '12 21:02

Trent Miller


1 Answers

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

like image 99
Book Of Zeus Avatar answered Oct 14 '22 06:10

Book Of Zeus