Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to redirect mobile user to mobile page

Tags:

php

mobile

I created mobile site for existing webpage and in it, I placed the code in mobile folder like www.testing.com/mobile and it works fine.

But what I need to do is if the user visited from mobile it should be redirected to mobile page and user visited from web it goes to default pages.

Here I used:

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0" /> 

to fit the page but url shows like m.tesing.com for mobile how to do this

By browser agent or any other ways. Thanks.

like image 384
papa.ramu Avatar asked Dec 06 '25 14:12

papa.ramu


1 Answers

Download this detectmobile.js and make this changes in your head tag

 <head>
                <script src="detectmobile.js"></script>
                <script>
                        try {
                                // This is the URL where mobile
                                detectmobile.defaultMobileURL = "http://m.testing.com";
                                detectmobile.process();
                        } catch(e) {
                                // Make sure that in the fault modes
                                // we do not interrupt execution of other Javascript code
                        }
                </script>
        </head>
like image 78
Thulasi Avatar answered Dec 08 '25 03:12

Thulasi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!