I wrote two filters that allow you to configure redirect rules for requests sent from special user agents e.g. iphone, android & co.
If the requesting user agent matches the redirect rules then the redirect is issued using HTTP Headers. As a fallback for cached pages, the redirect is issued again using javascript (the filter inserts some lines of javascript code in the
-section of your document).
The first one, redirectUserAgentFilter, is a generic approach to redirects depending on the user agent string. You can activate it in your filters.yml using these lines:
redirectUserAgent:
class: redirectUserAgentFilter
enabled: on
param:
redirectUrl: http://mobile.yourdomain.com
userAgents:
- android
- iphone
- ipod
In this case, the filter would redirect all requests coming from user agents containing “android”, “iphone” oder “ipod” in their names to http://mobile.yourdomain.com.
(more…)