How to redirect to the mobile version?

Tell me how to redirect to the mobile version of the site?
At the moment I do so - determine that it is a mobile device or PC, then call the correct part of the script, that is, require_once('/index.php'); or require_once('/index_mob.php'); while sitemap is the same...
Or as something else you need to do a separate subdomain, a separate sitemap ... ?
April 7th 20 at 10:57
1 answer
April 7th 20 at 10:59
Solution
There are 3 Ways of adapting the website for mobile devices:
1. Responsive design
2. Dynamic serving
3. Different URL

The first two do not require any redirection to the mobile version. The third requires.

Which method of the three better - theme holivarnaya, so I will limit myself to references to Habr:
Comparison of methods of creating mobile versions of sites
Whether to do a mobile version? 5 common Pro...

And the recommendations of the search engines how to make a mobile version of the website and the correct redirection to the mobile version:
Indexing by Yandex mobile version of the site on ...
Sites for mobile devices, recommendations Yandex
Recommendations Google if mobile/desktop vers...

In short - Google for 3rd method recommends that you register tags:
On the page for computers (http:// www.example.com/page-1) add the following code:
<link rel="alternate" media="only screen and (max-width: 640px)"
 href="http://m.example.com/page-1">

On the mobile homepage (http:// m.example.com/page-1) abstract should be:
<link rel="canonical" href="http://www.example.com/page-1">


Yandex recognizes the mobile version on subdomain, but does not recognize in a separate folder:
If the mobile version of the site located in a subdirectory of the main site, indexing Yandex robot will not be able to index the data and to recognize the website mobilephone. Use responsive design or dynamic layout

Find more questions by tags Search engine optimization