Problème de Redirection pour site Mobile

coldplay12 Messages postés 2 Statut Membre -  
coldplay12 Messages postés 2 Statut Membre -
Bonjour,
J'ai un petit problème.
Bon j'ai un site web et un autre en version mobile je voudrais que quand les internautes veulent se rendre sur mon site web via leur smartphones ils seront directement rediriger vers le site mobile pour le coup j'utilisai ce code sur le Htaccess de mon site


RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "ipod|iphone|ipad|android|palm|blackberry" [NC]
RewriteCond %{HTTP_HOST} !^/mobile
RewriteRule (.*) http://www.coldplaycorner.com/mobile [R=301,L]

Or depuis quelques semaines on a basculer le site mobile sur une adresse plus stable qui est www.m.coldplaycorner.com alors ma demande est la suivante comment je pourrais modifier le code afin qu'il marche car j'ai essayer et ça marche pas quand je met ça..

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "ipod|iphone|ipad|android|palm|blackberry" [NC]
RewriteCond %{HTTP_HOST} !^/mobile
RewriteRule (.*) http://www.m.coldplaycorner.com/ [R=301,L]

j'ai besoin de vos avis que sur cette ligne là..
RewriteCond %{HTTP_HOST} !^/mobile

1 réponse

  1. coldplay12 Messages postés 2 Statut Membre
     
    Problème réglé avec ce code...

    RewriteEngine on
    RewriteBase /
    # Check if this is the noredirect query string
    RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
    # Set a cookie, and skip the next rule
    RewriteRule ^ - [CO=mredir:0:www.website.com]

    # Check if this looks like a mobile device
    # (You could add another [OR] to the second one and add in what you
    # had to check, but I believe most mobile devices should send at
    # least one of these headers)
    RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
    RewriteCond %{HTTP:Profile} !^$ [OR]
    RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
    RewriteCond %{HTTP_USER_AGENT} !macintosh [NC]

    # Check if we're not already on the mobile site
    RewriteCond %{HTTP_HOST} !^m\.
    # Can not read and write cookie in same request, must duplicate condition
    RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$)

    # Check to make sure we haven't set the cookie before
    RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC]

    # Now redirect to the mobile site
    RewriteRule ^ http://m.coldplaycorner.com [R,L]


    Merci.
    0