Hello guys in this blog I will tell you how to redirect a website to a mobile version when accessed on a mobile device
Create a mobile website that provides a great user experience
Redirect your site for mobile users
Using a JavaScript code you can redirect your mobile visitors to your mobile site. This JS code can either detect screen size or the user-agent.
Open the HTML file or your website's code page
Search - <head> in your template
Copy and paste this code below the <head> tag
<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "mobile.html";
}
//-->
</script>
“mobile.html” would be replaced with the location of wherever your mobile version resides.
This technique could be adapted to load an alternate stylesheet as well.
For iPhones/iPods Specifically
<script language=javascript>
<!--
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
location.replace("http://url-to-send-them/iphone.html");
}
-->
</script>
And boom you are done

PHP Method
For this script to work your page extensions must be .php and your hosting account must support PHP. Add the following code to your website’s section.
<?php
$iphone = strpos($_SERVER[‘HTTP_USER_AGENT’],”iPhone”);
$android = strpos($_SERVER[‘HTTP_USER_AGENT’],”Android”);
$palmpre = strpos($_SERVER[‘HTTP_USER_AGENT’],”webOS”);
$berry = strpos($_SERVER[‘HTTP_USER_AGENT’],”BlackBerry”);
$ipod = strpos($_SERVER[‘HTTP_USER_AGENT’],”iPod”);
if ($iphone || $android || $palmpre || $ipod || $berry == true)
{
echo “<script>window.location=’http://m.site.com'</script>”;
}
?>