A
A
Aibek Kendirbaev2015-03-18 09:17:11
PHP
Aibek Kendirbaev, 2015-03-18 09:17:11

HTACCESS and redirect on screen resolution?

How to make a redirect to the mobile version of the site if the user comes from a tablet (portrait) and leave it on the main page if from a tablet (landscape)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
swcalc, 2015-03-18
@stan11

980 - the width of the browser window, of course, you should choose the optimal one.
And call the function, as you prefer, either by loading or by onresize.

function redirect() {
    if (window.offsetWidth<=980) {
        window.location.replace('/mobile=1');
    }
}

S
Sergey Chizhik, 2015-03-18
@kzooz

It is impossible to do this at the web server level, because the server does not own the device information when it receives an HTTP request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question