Need help creating mobile redirect PHP script

Hi guys,

I have a desktop site and a mobile/tablet version of the site too. I need a PHP script to go in the index.php file which essentially says, if viewing on a mobile/tablet device switch to the mobile URL but if viewing on desktop, continue loading the rest of index.php.

I’ve found loads of scripts but they all seem to be something that redirects to two URLs - one to a mobile site or one to a desktop version - really, I need a script that will sit at the top of the existing index page and either redirect to the mobile URL or continue to load index.php.

Does anyone know how I can do this or have any ideas how I can do this?

Thank you very much for any help.

SM :slight_smile:

In MHO, you should css media queries to define elements on the page and a fluid layout design. I am not aware of any server-side device detection, php or otherwise. It is only after headers are sent that screen can be detected with JS, css etc.
http://css-tricks.com/snippets/css/media-queries-for-standard-devices/

Building off what Drummin said, why do you feel like you need two versions of the same page? Seems a waste TBH. Make your design responsive (by use of media queries.)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.