{"id":1374,"date":"2014-11-11T21:08:26","date_gmt":"2014-11-11T21:08:26","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=1374"},"modified":"2014-11-11T21:08:26","modified_gmt":"2014-11-11T21:08:26","slug":"how-to-redirect-url-to-mobile-website","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2014\/11\/how-to-redirect-url-to-mobile-website\/","title":{"rendered":"How to Redirect URL to Mobile Website ?"},"content":{"rendered":"<p>If you have mobile version of website and want to redirect to appropriate devices this code could be useful.<br \/>\nAdd this code to header or index.php file.<\/p>\n<pre lang=\"php\">\r\n<?php\r\n$iphone = strpos($_SERVER['HTTP_USER_AGENT'],\"iPhone\");\r\n$android = strpos($_SERVER['HTTP_USER_AGENT'],\"Android\");\r\n$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],\"webOS\");\r\n$berry = strpos($_SERVER['HTTP_USER_AGENT'],\"BlackBerry\");\r\n$ipod = strpos($_SERVER['HTTP_USER_AGENT'],\"iPod\");\r\n\r\nif ($iphone || $android || $palmpre || $ipod || $berry == true) \r\n{\r\n    echo \"<script>window.location='http:\/\/www.phpmind.com'<\/script>\";\r\n }\r\n?>\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you have mobile version of website and want to redirect to appropriate devices this code could be useful. Add this code to header or index.php file.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[48],"tags":[],"class_list":["post-1374","post","type-post","status-publish","format-standard","hentry","category-mobile"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/comments?post=1374"}],"version-history":[{"count":1,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1374\/revisions"}],"predecessor-version":[{"id":1375,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1374\/revisions\/1375"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=1374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=1374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=1374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}