Created
March 23, 2012 17:11
-
-
Save RichardBronosky/2172856 to your computer and use it in GitHub Desktop.
/services/apache/conf.d/django/prod/includes/mobile-redirects.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Mobile logic to direct users to mobile or full sites | |
| # Enforce destination to not be origin. Interim hack to allow mobile sites to redirect when returning from Akamai. -MH | |
| RewriteCond %{HTTP_HOST} ^origin\. | |
| RewriteRule ^(.*)$ %{HTTP_HOST}$1 [C] | |
| RewriteRule ^origin\.([^/]+)(/.*)$ $2 [C,E=DEST_HOST:$1,PT] | |
| RequestHeader set Host %{DEST_HOST}e env=DEST_HOST | |
| # Do not apply any further rules to lsp., news. or signin. domains | |
| RewriteCond %{HTTP_HOST} ^(lsp|signin|news|lab)\. [NC] | |
| RewriteRule .* - [L] | |
| # Define the MOBILE_PATTERN (for user agent detection) ONLY for pages who are NOT black listed from mobile. (TODO: Try using a whitelist instead. Would probably be shorter.) | |
| # While clark is on Soloist, he must always receive the MOBILE_PATTERN | |
| RewriteCond %{HTTP_HOST} clarkhoward [OR] | |
| RewriteCond %{REQUEST_URI} !^/(ads|alerts|answers|audioclips|bands|categories|categories|events|documents|drinkspecials|events|features|forums|instruments|maps|mp3|lsp|onthestreet|places|playlists|podcasts|polls|pr|qa|questionnaires|recipes|restaurants|restaurants|specials|search|songs|special_coverage|staff|stories|traffic|tumble) [NC] | |
| # The env var is used by django templates and client side javascript. Even though it is only used as a boolean flag here, it needs to remain a legit regex for app code. | |
| RewriteRule .* - [E=MOBILE_PATTERN:iphone|ipod|android|blackberry|symbian|nokia|sonyericsson|sie-|opera\ mini|portalmmm/|windows\ ce|windows\ phone|iemobile|up.browser|up.link|802sh|alcatel-|amoi-|attws|au-mic|audiovox|avantgo|benq|cdm-|ericsson|ericy-|gs308|hitachi-p300|htc-|i-2100|kwc-|lg-|lg/u|lge-|lge/u|lowestcd|mo0|mobilephone|mot-|motorola|n5-10|nec-|opwv|owg1|palm|panasonic|pg-c|philips|pls|pm-|pn-215|profile/midp|qci-|rl-|rpt-httpclient|sagem|samsung|sanyo|sch-a|sch-n|scp-|sec-|sendox|sgh|sharp|smartphone|spha|v60t|vi600|vk530|vm4050|vodafone|wapper|wildseed|winwap-pro] | |
| # Any user hitting the bare domain with either the cookie or the query string goes to the full site | |
| RewriteCond %{HTTP_HOST} !^www\..+ [NC] | |
| RewriteCond %{HTTP_HOST} !^my\..+ [NC] | |
| RewriteCond %{HTTP_HOST} !^m\..+ [NC] | |
| RewriteCond %{HTTP_HOST} !^lab\..+ [NC] | |
| RewriteCond %{REQUEST_URI} !/fullsite | |
| RewriteCond %{REQUEST_URI} !/mobilesite | |
| RewriteCond %{QUERY_STRING} nmredir=true [OR] | |
| RewriteCond %{HTTP_COOKIE} nmredir=true | |
| RewriteRule (.*) http://www.%{HTTP_HOST}$1 [R=302,L] | |
| # Adding the next two sections to override selected tv sites to LSN | |
| RewriteCond %{HTTP_HOST} ^m\.(wftv.com|foxreno.com|wtov9.com|wjactv.com|wsbtv.com|kfoxtv.com|kirotv.com|ktvu.com|whiotv.com|wsoctv.com|wpxi.com)$ | |
| #RewriteRule (.*) http://wap.%1 [R=302,L] | |
| RewriteRule (.*) http://wap.%1/?targetUrl=http://www.%1$1 [R=302,L] | |
| RewriteCond %{HTTP_USER_AGENT} iphone|ipod|android|blackberry|symbian|nokia|sonyericsson|sie-|opera\ mini|portalmmm/|windows\ ce|windows\ phone|iemobile|up.browser|up.link|802sh|alcatel-|amoi-|attws|au-mic|audiovox|avantgo|benq|cdm-|ericsson|ericy-|gs308|hitachi-p300|htc-|i-2100|kwc-|lg-|lg/u|lge-|lge/u|lowestcd|mo0|mobilephone|mot-|motorola|n5-10|nec-|opwv|owg1|palm|panasonic|pg-c|philips|pls|pm-|pn-215|profile/midp|qci-|rl-|rpt-httpclient|sagem|samsung|sanyo|sch-a|sch-n|scp-|sec-|sendox|sgh|sharp|smartphone|spha|v60t|vi600|vk530|vm4050|vodafone|wapper|wildseed|winwap-pro [NC] | |
| RewriteCond %{HTTP_HOST} (wftv.com|foxreno.com|wtov9.com|wjactv.com|wsbtv.com|kfoxtv.com|kirotv.com|ktvu.com|whiotv.com|wsoctv.com|wpxi.com) | |
| RewriteRule (.*) http://wap.%1 [R=302,L] | |
| # Any user hitting the bare domain with the mobile pattern who didn't match above and are (not clarkhoward or not using non-mobilized content) go to the mobile site | |
| RewriteCond %{HTTP_HOST} !^www\..+ [NC] | |
| RewriteCond %{HTTP_HOST} !^my\..+ [NC] | |
| RewriteCond %{HTTP_HOST} !^m\..+ [NC] | |
| RewriteCond %{HTTP_HOST} !^lab\..+ [NC] | |
| RewriteCond %{REQUEST_URI} !/fullsite | |
| RewriteCond %{REQUEST_URI} !/mobilesite | |
| RewriteCond %{HTTP_USER_AGENT} iphone|ipod|android|blackberry|symbian|nokia|sonyericsson|sie-|opera\ mini|portalmmm/|windows\ ce|windows\ phone|iemobile|up.browser|up.link|802sh|alcatel-|amoi-|attws|au-mic|audiovox|avantgo|benq|cdm-|ericsson|ericy-|gs308|hitachi-p300|htc-|i-2100|kwc-|lg-|lg/u|lge-|lge/u|lowestcd|mo0|mobilephone|mot-|motorola|n5-10|nec-|opwv|owg1|palm|panasonic|pg-c|philips|pls|pm-|pn-215|profile/midp|qci-|rl-|rpt-httpclient|sagem|samsung|sanyo|sch-a|sch-n|scp-|sec-|sendox|sgh|sharp|smartphone|spha|v60t|vi600|vk530|vm4050|vodafone|wapper|wildseed|winwap-pro [NC] | |
| RewriteCond %{ENV:MOBILE_PATTERN} .+ | |
| RewriteRule (.*) http://m.%{HTTP_HOST}$1 [R=302,L] | |
| # Everyone else hitting the bare domain goes to the full site | |
| RewriteCond %{HTTP_HOST} !^www\..+ [NC] | |
| RewriteCond %{HTTP_HOST} !^my\..+ [NC] | |
| RewriteCond %{HTTP_HOST} !^m\..+ [NC] | |
| RewriteCond %{HTTP_HOST} !^lab\..+ [NC] | |
| RewriteCond %{REQUEST_URI} !/fullsite | |
| RewriteCond %{REQUEST_URI} !/mobilesite | |
| RewriteRule (.*) http://www.%{HTTP_HOST}$1 [R=302,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment