Created
August 30, 2012 01:42
-
-
Save sheeplogh/3521534 to your computer and use it in GitHub Desktop.
[mod_rewrite]Redirect HTTP requests by UA(PC/Smartphone/...)
This file contains 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
## SET ENV "UA" ## | |
### DEFAULT | |
RewriteRule .* - [E=UA:default] | |
### PC | |
RewriteCond %{HTTP_USER_AGENT} Windows [NC,OR] | |
RewriteCond %{HTTP_USER_AGENT} Mac\sOS\sX [NC,OR] | |
RewriteCond %{HTTP_USER_AGENT} Macintosh [NC,OR] | |
RewriteCond %{HTTP_USER_AGENT} Mac_ [NC,OR] | |
RewriteCond %{HTTP_USER_AGENT} Linux [NC,OR] | |
RewriteCond %{HTTP_USER_AGENT} BlackBerry [NC] | |
RewriteRule .* - [E=UA:pc] | |
### SmartPhone | |
RewriteCond %{HTTP_USER_AGENT} Windows\sPhone [NC,OR] | |
RewriteCond %{HTTP_USER_AGENT} like\sMac\sOS\sX [NC,OR] | |
RewriteCond %{HTTP_USER_AGENT} Android [NC] | |
RewriteRule .* - [E=UA:sp] | |
### CDN edge server | |
RewriteCond %{HTTP_USER_AGENT} Amazon\sCloudFront [NC] | |
RewriteRule .* - [E=UA:cdn] | |
## REDIRECTION ## | |
### PC | |
RewriteCond %{ENV:UA} pc | |
RewriteRule ^/(.*)$ /pc/$1 [R,L] | |
### SmartPhone | |
RewriteCond %{ENV:UA} sp | |
RewriteRule ^/(.*)$ /sp/$1 [R,L] | |
### CDN edge server | |
RewriteCond %{ENV:UA} cdn | |
RewriteRule .* - [L] | |
### Others | |
RewriteCond %{ENV:UA} default | |
RewriteRule ^/(.*)$ /pc/$1 [R,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment