I have different domain names for mobile (http://m.mydomain.com) and desktop (http://web.mydomain.com) users. I am currently using following Javascript code to redirect my desktop users accessing mobile URLs to desktop URLs.
<script>
var isDesktop = {
Windows: function() {
return navigator.platform.match('Win32|Win16|Win64|WinCE|Windows');
},
Mac: function() {
return navigator.platform.match('MacIntel|Macintosh|MacPPC|Mac68K');
},
any: function() {
return (isDesktop.Windows() || isDesktop.Mac());
}
};
if (isDesktop.any()){
window.location='http://web.mydomain.com';
}
</script>
But the issue is: The user is redirected to main-page (http://web.mydomain.com) no matter on which page he is. I want to redirect them to the respective page. For example, if a desktop user is accessing the mobile page http://m.mydomain.com/a-page, he is automatically redirected to desktop version of that page http://web.mydomain.com/a-page.
I can't use .htaccess because my web-server is Nginx.