#con regex da http://detectmobilebrowsers.com/ |
| funziona bene ho provato !! |
| |
| #set $ variabile mobile_rewrite |
| imposta $ mobile_rewrite do_not_perform; |
| |
| if ($ http_user_agent ~ * "(android | bb \ d + | meego). + mobile | avantgo | bada \ / | blackberry | blazer | compal | elaine | fennec | hiptop | iemobile | ip (hone | od) | iris | kindle | lge | maemo | midp | mmp | mobile. + firefox | netfront | opera m (ob | in) i | palm (os)? | phone | p (ixi | re) \ / | plucker | pocket | psp | series ( 4 | 6) 0 | symbian | treo | up \. (Browser | link) | vodafone | wap | windows ce | xda | xiino ") { |
| eseguire $ mobile_rewrite eseguire; |
| } |
| |
| if ($ http_user_agent ~ * "^ (1207 | 6310 | 6590 | 3gso | 4thp | 50 [1-6] i | 770s | 802s | a wa | abac | ac (er | oo | s \ -) | ai (ko | rn) | al (av | ca | co) | Amoi | un (ex | ny | w) | APTU | ar (ch | andare) | come (TE | us) | attw | au (di | \ -m | r | s) | avan | be (ck | ll | nq) | bi (lb | rd) | bl (ac | az) | br (e | v) w | bumb | bw \ - (n | u) | c55 \ / | CAPI | ccwa | cdm \ - | cella | chtm | CLDC | cmd \ - | co (mp | nd) | Craw | da (it | ll | ng) | dbte | dc \ -s | Devi | dica | dmob | fare (c | p) o | ds (12 | \ -d) | el (49 | AI) | em (L2 | ul) | er (ic | k0) | esl8 | ez ([4-7] 0 | os | wa | ze) | fetc | fly (\ - | _) | g1 u | g560 | gene | gf \ -5 | g \ -mo | go (\.w | od) | gr (ad | un) | haie | hcit | hd \ - (m | p | t) | hei \ - | hi (pt | ta) | hp (i | ip) | hs \ -c | ht (c (\ - | | _ | a | g | p | s | t) | tp) | hu (aw | tc) | i \ - (20 | go | ma) | i230 | iac (| \ - | \ /) | ibro | idea | ig01 | ikom | im1k | inno | ipaq | iris | ja (t | v) a | jbro | jemu | jigs | kddi | keji | kgt (| \ /) | klon | kpt | kwc \ - | kyo (c | k) | le (no | xi) | lg (g | \ / (k | l | u) | 50 | 54 | \ - [aw]) | libw | lynx | m1 \ -w | m3ga | M50 \ / | mA (TE | ui | xo) | MC (01 | 21 | ca) | m \ -CR | me (rc | RI) | mi (O8 | OA | ts) | MMEF | mo ( 01 | 02 | bi | de | do | t (\ - | | o | v) | zz) | mt (50 | p1 | v) | MWBP | mywa | n10 [0-2] | n20 [2-3] | n30 (0 | 2) | n50 (0 | 2 | 5) | N7 (0 (0 | 1) | 10) | NE ( (c | m) \ - | on | TF | wf | ca | peso) | nok (6 | i) | nzph | o2im | op (ti | wv) | Oran | owg1 | P800 | pan (a | m | ) | pdxg | pg (13 | \ - ([1-8] | c)) | Phil | pire | pl (ay | UC) | pn \ -2 | Po (ck | rt | SE) | prox | PSIO | pt \ -g | qa \ -a | qc (07 | 12 | 21 | 32 | 60 | \ - [2-7] | i \ -) | Qtek | R380 | r600 | raks | rim9 | ro (vE | zo ) | S55 \ / | sa (GE | ma | mm | ms | ny | VA) | sc (01 | h \ - | oo | p \ -) | sdk \ / | SE (c (\ - | 0 | 1 ) | 47 | mc | ND | RI) | sgh \ - | shar | sie (\ - | m) | sk \ -0 | sl (45 | id) | sm (al | ar | b3 | it | t5) | quindi (ft | ny) | sp (01 | h \ - | v \ - | v) | sy (01 | mb) | t2 (18 | 50) | t6 (00 | 10 | 18) | ta (gt | lk ) | tcl \ - | TDG \ - | tel (i | m) | tim \ - | t \ -MO | a (pl | SH) | ts (70 | m \ - | m3 | M5) | tx \ -9 | up (\ b |. g1 | SI) | UTST | V400 | V750 | Veri | VI (rg | TE) | VK (40 | 5 [0-3] | \ -v) | VM40 | voda | Vulc | vx (52 | 53 | 60 | 61 | 70 | 80 | 81 | 83 | 85 | 98) | w3c (\ - |) | webc | whit | wi (g | nc | nw) | wmlb | wonu | x700 | yas \ - | your | zeto | zte \ -) ") {) {) { |
| eseguire $ mobile_rewrite eseguire; |
| } |
| |
| # controlla se query arg = yes (esempio.com?mobile=yes), imposta variabile |
| if ($ arg_mobile = 'yes') { |
| add_header Set-Cookie mobile = yes; |
| eseguire $ mobile_rewrite eseguire; |
| } |
| |
| # controlla se cookie mobile = yes, imposta variabile |
| if ($ cookie_mobile = 'yes') { |
| eseguire $ mobile_rewrite eseguire; |
| } |
| |
| # controlla se cookie mobile = no, interrompi |
| if ($ cookie_mobile = 'no') { |
| imposta $ mobile_rewrite do_not_perform; |
| } |
| |
| # controlla se query arg = no (esempio.com?mobile=no), break |
| if ($ arg_mobile = 'no') { |
| add_header Set-Cookie mobile = no; |
| imposta $ mobile_rewrite do_not_perform; |
| } |
| |
| #if $ mobile_rewrite = esegui, esegui il reindirizzamento |
| se ($ mobile_rewrite = esegui) { |
| return 301 $ scheme: //mobile.domain.com$request_uri; |
| } |