0

I want to create website which is for mobile version or desktop version. This is possible to create new subdomain of my domain & launch it for mobile . All request which is come from mobile redirect to mobile version folder.

But i want to create same url for desktop version & mobile version site but the directory are different.

For example:

My domain is www.abc.com for desktop version for mobile version www.abc.com/m this is physically folder structure of site. But i want when user type www.abc.com from mobile its show mobile version website and from desktop for same url.

Pupil
  • 23,834
  • 6
  • 44
  • 66
Rahul Gupta
  • 93
  • 1
  • 3
  • 13

2 Answers2

1

Please see the top answer for this question: Auto detect mobile browser (via user-agent?) It details how to use the User-Agent header to check if a mobile browser is accessing your site, and redirect to the mobile part of your website, just like you stated.

Alternatively if you're using a CMS like Joomla or Drupal, a quick google search will show you how to plug-in a mobile version.

Community
  • 1
  • 1
Drei
  • 91
  • 2
  • Yeah Drei, i am able to check user-agent. Condition is url will not change for mobile version and desktop version but the directories are different for mobile and desktop version. – Rahul Gupta Sep 24 '13 at 07:08
  • As Gefferey said in his comment, you could run with just the one same, say, index.php file - and have logic in there to load things from /m if the user-agent is a mobile device. – Drei Sep 24 '13 at 13:53
0

the simpliest way would detect the user agent, if it is a mobile user agent, you could redirect the user to the mobile website. using php would be

<?php
 $browser = get_browser(null, true);
 //check the $browser to see if it has mobile platform or desktop
 if (mobile) header ('location:www.abc.com/m')
 if (desktop) header ('location:www.abc.com')

?>

FYI, see the docs here http://php.net/manual/en/function.get-browser.php

  • Condition is url will not change for mobile version and desktop version but the directories are different for mobile and desktop version. – Rahul Gupta Sep 24 '13 at 07:04
  • if it is the case, you would have to use front controller design pattern, so it can render view according to different request – Gefferey Zhang Sep 24 '13 at 07:12