301 Redirection For Mobile Site |
- Copy below given code in step 2 and paste in to the blank line:
<script type="text/javascript">
<!--
if (screen.width <= 699)
<!--
if (screen.width <= 699)
{
document.location = "filename.html";
}
//-->
</script>
document.location = "filename.html";
}
//-->
</script>
- Replace "filename.html" with the name of mobile web page, relative to website root.
example:
document.location = "/m/index.html";
document.location = "/m/index.html";
Or:
document.location = "mobile.html";
document.location = "mobile.html";
Given code will redirect to any device with a screen width below 699 pixels to mobile site.
You may adjust the screen width to 480 if you want to target iPhones & other Smartphones
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
{
location.replace("http://www.yoursite.com/iPhone.html");
}
location.replace("http://www.yoursite.com/iPhone.html");
}
Replace " http://www.yoursite.com/iPhone.html" with the URL to iPhone-optimized website.