Detect iPhone browser in .htaccess/apache and redirect to iPhone site

后端 未结 4 1408
伪装坚强ぢ
伪装坚强ぢ 2021-02-03 15:29

Is it possible to detect iPhone browser agent in .htaccess and redirect the user to the correct iPhone page?

4条回答
  •  伪装坚强ぢ
    2021-02-03 16:16

    Sure you can -

       #redirect mobile browsers
        RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
        RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
        RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$
        RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
        RewriteCond %{HTTP_USER_AGENT} ^.*Palm.*$
        RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
    

    Taken from here

提交回复
热议问题