我想在.htaccess apache文件中设置移动的env-var
我有:
SetEnvIf User-Agent "iPhone" devicetype
SetEnvIf User-Agent "Android" devicetype
RewriteRule ^ - [E=DEVICE:%{devicetype}]
但是我的$_SERVER['DEVICE']总是空的。为什么?
您的规则将设置$_SERVER['devicetype']
[devicetype] => 1
您不需要:RewriteRule ^ - [E=DEVICE:%{devicetype}]
如果你喜欢,你可以使用这个:
RewriteCond %{HTTP_USER_AGENT} "iphone|android" [NC] # i put 2 as example
RewriteRule ^ - [E=DEVICE:mobile]
这将把$_SERVER['DEVICE']设置为mobile