As a developer you might want to redirect your web version of the site to mobile version. As we know that all of us get’s quite busy with our day to day schedules, but we really want to be connected with world via internet on the move, and while leaving in the era of mobile devices it is all possible now a days. You simply have to follow very simple steps to redirects any user to the mobile version form web version of your website or vice versa:
Redirection can be done from both sides:
1. Redirect user to Mobile Version.
2. Redirect user to Web Version.
1. Redirect from Web Version to Mobile Version:
Navigate to header.php of your Web version & place the following code in <head> section:
<script language="javascript">
var query = window.location.search.substring(1);
var redirect = getQueryStringParameterByName(query, "redirect");
if (redirect!="temp")
{
var redirectagent = navigator.userAgent.toLowerCase();
var redirect_devices = ['vnd.wap.xhtml+xml', 'sony', 'symbian', 'nokia', 'samsung', 'mobile', 'windows ce', 'epoc', 'opera mini', 'nitro', 'j2me', 'midp-', 'cldc-', 'netfront', 'mot', 'up.browser', 'up.link', 'audiovox', 'blackberry', 'ericsson', 'panasonic', 'philips', 'sanyo', 'sharp', 'sie-', 'portalmmm', 'blazer', 'avantgo', 'danger', 'palm', 'series60', 'palmsource', 'pocketpc', 'smartphone', 'rover', 'ipaq', 'au-mic', 'alcatel', 'ericy', 'vodafone', 'wap1', 'wap2', 'teleca', 'playstation', 'lge', 'lg-', 'iphone', 'android', 'htc', 'dream', 'webos', 'bolt', 'nintendo'];
for (var i in redirect_devices)
{
if (redirectagent.indexOf(redirect_devices[i]) != -1)
{
location.replace("http://mobile.yoursitename.com");
}
}
}
function getQueryStringParameterByName(queryString, paramName)
{
tokens = queryString.split("&");
if (tokens!=null)
{
for (i=0;i<tokens.length;i++)
{
ft = tokens[i].split("=");
if (ft[0] == paramName)
{
if (ft[1].indexOf("%20",0)>0)
{
var returnValue = ft[1].replace("%20"," ");
returnValue = returnValue.replace("%20"," ");
return returnValue;
}
return ft[1];
}
}
return "";
}
}</script>
In the above code we’ve used location.replace(“http://mobile.yoursitename.com”);
You can replace “http://mobile.yoursitename.com” by your mobile site URL.
2. Redirect from Mobile Version to Web Version:
Add the following code in footer.php of your mobile version of the site:
<a target="_blank" href="http://yoursitename.com/index.php?redirect=temp">Full Site</a>
In the above code we’ve used “http://yoursitename.com/index.php”. You can replace that by the name of your site(Web Version).
What are you waiting for?? Employ the above code and do the redirection.







That’s some cool info. Good post.
Very useful.
Stumbled into this web site by chance but I’m sure glad I clicked on that link. You definitely answered all of the questions I’ve been dying to answer for some time now. Will genuinely occur back for additional of this. Thank you so much
This site is really a walk-through for all of the info you wanted about this and didn’t know who to ask. Glimpse here, and you’ll definitely discover it.
Thanks Garmen,
I really appreciate your comments. Very soon I am going to launch in built forums in this site, so where you can ask your queries. In the mean while if you want you can mail your queries at tips4developer@gmail.com. I will definitely try to solve your queries regarding WP and Joomla and place it as a post.
Also I am looking forward to promote my site with your friends
-Amit
1 of 2 things, first I think your correct and second I think you really know how to write so people understand what you are trying to say. a+ keep up the fantastic work.
Keep functioning, terrific job!
Undeniably believe that which you stated. Your favorite reason seemed to be on the web the easiest thing to be aware of. I say to you, I certainly get annoyed while people consider worries that they just do not know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side-effects , people could take a signal. Will likely be back to get more. Thanks
Heya i am for the first time here. I came across this board and I find It truly useful & it helped me out a lot. I hope to give something back and help others like you aided me.
Very nice post. I just stumbled upon your weblog and wished to say that I have truly enjoyed browsing your blog posts. After all I will be subscribing to your rss feed and I hope you write again very soon!
Nice, straight-forward way of handling this. Thanks for sharing!