Very little I understand in hosting, in the mechanics of servers and other things, and even more so in redirects. I can only make up a little. The one-page site has collapsed, and here is the problem: I use a script that does not look in the mobile version and breaks it in every way. I decided that I will not be able to adapt this and will quickly make a separate mobile version of the site (<768px). Please explain very clearly how and what to do. Here is the site donsocks.ru I use cPanel on the host. Thanks for any help.
- Make for the mobile version of the sub-domain m.donsocks.ru then on the main donsocks.ru make a detector, by user agents, and so on, and if it is a mobile or tablet, redirect to m.donsocks.ru But if you do everything on one domain it is better to make a responsive design. - webstackoverload
|
2 answers
You can connect a library to define mobile devices http://code.google.com/p/php-mobile-detect/
Further on the pages of the site at the beginning to add:
<?php include 'Mobile_Detect.php'; $detect = new Mobile_Detect(); if ($detect->isMobile()) { header('Location: yourpage.php'); // страница для переадресации exit(0); } ?> Usage examples https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples
- Can I insert this if I have index.html and not php? - rounezzzzz
- @rounezzzzz you can change the file format and then it will work. Instead of
index.htmlmakeindex.php. - Dmitry B. - i added thanks, helped - rounezzzzz
|
I think you can insert the code on php
header( 'Location: http://yandex.ru/yandsearch?text=redirect', true, 301 ); // сделать переадресацию с помощью 301 редиректа на поиск в Яндексе слова redirect. header( 'Location: http://google.ru/search?q=redirect' ); // с помощью 302 редиректа переадресовывать на поиск в гугле слова redirect (При использовании Location без указания кода редиректа, по умолчанию используется 302-й). header( 'Location: /article/page.htm', true, 303 ); // с помощью 303 редиректа переадресовать на внутреннюю страницу сайта. header( 'Location: /', true, 307 ); // перебросить на главную страницу сайта с использованием 307 редиректа. header( 'Refresh: 5; url=http://rambler.ru/' ); // переадресовать на главную страницу Рамблера через 5 секунд после загрузки страницы. header( 'Refresh: 0; url=/error404.html' ); // переадресовать на страницу ошибки немедленно (без задержки). I am not strong in php, but it seems that the latter method works well)
|