PHP Code to Redirect Mobile/Handheld Users

With the amount of people walking around using iPhones or some sort of Blackberry or PDA, it makes sense to provide an alternative landing page for Mobile/Handheld users that is formatted for their device. I was recently hired to create a mobile page by a client and found a great piece of code to help with the whole redirection issue. The folks over at Detect Mobile Browsers have developed a great tool that checked to see if a user has reached your site through a Mobile/Handheld device, and if so will redirect to the page your choice. Just download the code off of their site and use their handy Function Generator to configure it how you want. To configured it to treat everything as a Mobile/Handheld device use this code.

To add an if statement to only make it redirect if it is the home page use this.

Add this to the top of your header.php file and uploaded their mobile_device_detect.php file to your main directory. If you are not using WordPress, just add the first bit of code above (without the if statement) to the top of your index.php file. NOTE: This will only work if your site is built with PHP.
Search

Popular Posts

Small Biz Website Tips Newsletter

Stay up to date with the latest marketing, sales, and service tips and news.

Small Biz Website Tips Newsletter

Stay up to date with the latest marketing, sales, and service tips and news.