A
A
AFlash2015-09-19 22:25:17
PHP
AFlash, 2015-09-19 22:25:17

How to check the operating system on the site and give the appropriate redirect?

Good day! I really need a script // etc, which will determine the device through which they entered the site. There are a lot of scripts, but they are all adapted to the definitions of mobile devices. It is required to skip (or redirect) all devices (mobile//linux//etc) to one site, except for devices on OS Windows. If the site is visited from Windows, then a redirect to another site should occur. How is it possible to implement this? Thank you in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
AFlash, 2015-09-19
@AFlash

Thanks everyone for the replies. Solved the problem using JavaScript.
For those like me, I post my solution to the problem:

var os = 0;
if (navigator.userAgent.indexOf ('Windows') != -1) os = 1;
// alert(navigator.userAgent);
switch (os) {
   case 1:
       window.location.href = "http://site.ru";
      break;
   }

Also, solutions can be not only for Windows, but for all OS:
var os = 0;
if (navigator.userAgent.indexOf ('Windows') != -1) os = 1;
if (navigator.userAgent.indexOf ('Linux')!= -1) os = 2;
if (navigator.userAgent.indexOf ('Mac')!= -1) os = 3;
if (navigator.userAgent.indexOf ('FreeBSD')!= -1) os = 4;
// alert(navigator.userAgent);
switch (os) {
   case 1:
      window.location.href = "http://site.ru/windows";
      break;
   case 2:
      window.location.href = "http://site.ru/linux";
      break;
   case 3:
      window.location.href = "http://site.ru/mac_os";
      break;
   case 4:
      window.location.href = "http://site.ru/freebsd";
      break;
   default:
      window.location.href = "http://site.ru/other_os";
      break;
}

O
Optimus, 2015-09-19
Pyan @marrk2

See $_SERVER on the site - it has an OS

A
Alexander Taratin, 2015-09-19
@Taraflex

https://secure.php.net/manual/en/function.get-brow...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question