Sysop:ApacheUserAgentAndProxy
Version vom 15. Februar 2012, 23:06 Uhr von Admin (Diskussion | Beiträge)
Apache user-agent detection behind a proxy
Konfiguration for a server side browser-dependant redirect based on mod_rewrite, that works well behind a proxy:
# Browserdetection # # detection is only done when getting / <LocationMatch "^/$"> # set this header to support user-agent # detection through a caching proxy # since mod_rewrite does not do it for us # (s. http://stackoverflow.com/questions/3698363/mod-rewrite-not-sending-vary-accept-language-when-rewritecond-matches) Header always merge Vary User-Agent </LocationMatch> # # detect mobile useragents and redirect them to the mobile domain RewriteEngine on RewriteCond %{HTTP_USER_AGENT} (iphone|ipod) [OR] RewriteCond %{HTTP_USER_AGENT} (android) [OR] RewriteCond %{HTTP_USER_AGENT} (iemobile) [OR] RewriteCond %{HTTP_USER_AGENT} (blackberry) [OR] RewriteCond %{HTTP_USER_AGENT} (symbian) [NC] RewriteRule ^/$ http://mobile.mywebpage.com [R=301,L] # # all other browsers we point to index.html # so they are cached without the vary header set RewriteRule ^/$ http://mywebpage.com/index.html [R=301,L]