As we got more into the redirect we found that there were other features that we could add to improve the redirect. I will summarize what the below code does in order to select what traffic to redirect.
The traffic cannot have a path/query with /mobi, it means that the URL does not contain the mobile path which may or may not be intentional. The traffic must not have the mobile=false query string which we use to designate that the user has chosen to use the full version of the site. The traffic cannot have the /lib/ path because this is used for the pdfs and other documents and redirect this traffic will not allow those to be downloaded. The last requirement is that the HTTP Request contains a User-Agent that is for a mobile device. (Android, iPhone, iPod, BlackBerry, Windows Phone, IEMobile, webOS)
Responder
Action for All Mobile Redirects
HTTP.REQ.URL.PATH_AND_QUERY.TO_LOWER.CONTAINS("/mobi").NOT
&& HTTP.REQ.URL.PATH_AND_QUERY.TO_LOWER.CONTAINS("mobile=false").NOT
&& HTTP.REQ.URL.PATH_AND_QUERY.CONTAINS("/lib/").NOT &&
(HTTP.REQ.HEADER("User-Agent").CONTAINS("Android") ||
HTTP.REQ.HEADER("User-Agent").CONTAINS("iPhone") ||
HTTP.REQ.HEADER("User-Agent").CONTAINS("iPod") ||
HTTP.REQ.HEADER("User-Agent").CONTAINS("BlackBerry") ||
HTTP.REQ.HEADER("User-Agent").CONTAINS("Windows Phone") ||
HTTP.REQ.HEADER("User-Agent").CONTAINS("IEMobile") ||
HTTP.REQ.HEADER("User-Agent").CONTAINS("webOS"))
TL;DR
Traffic that gets switched meets the below conditions
- Does not contain /mobi in the path and query
- Does not contain the mobile=false querystring
- Does not contain /lib/ in the path.
- Does not contain a mobile device User-Agent
Responder Action for All Mobile Redirects:
Type: Redirect
http://www.intranet.com/mobile (Dummy link)
Responder Policy for Maintaining Full Version:
HTTP.REQ.HEADER("Referer").TO_LOWER.CONTAINS("mobile=false") && HTTP.REQ.URL.PATH_AND_QUERY.TO_LOWER.CONTAINS("mobile=false").NOT
If the referer contains mobile=false and the request URL does NOT contain mobile=false, we add &mobile=false to the end of the path and query. This maintains the Full Version status that was requested.
Responder Action for Maintaining Full Versions:
Type: Redirect
"http://" + HTTP.REQ.HOSTNAME + HTTP.REQ.URL.PATH_AND_QUERY + "&mobile=false"
Responder Policy for new Full Version Requests:
HTTP.REQ.HEADER("Referer").TO_LOWER.CONTAINS("mobile=false") && HTTP.REQ.URL.PATH_AND_QUERY.CONTAINS("?").NOT
If the user clicks the hyperlink (containing mobile=false) and they did not have a ? in the path and query, they get moved to the Full Version by adding a ?mobile=false to the path and query.
Responder Action for new Full Version Requests:
Type: Redirect
"http://" + HTTP.REQ.HOSTNAME+ HTTP.REQ.URL.PATH_AND_QUERY + "?mobile=false"
No comments:
Post a Comment