View My Site on Desktop only - block mobile access

I have a website that I only want viewed from a regular web browser on a desktop or laptop.  I don't want it viewed from a phone or ipad, etc.  

How do I create an else statement that  will direct desktop users to the website if you are on a desktop or laptop?

PHP is the code this site is written in

Thank you.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

why ?

phones and tablets are becoming more and more mainstream for browsing the web

are you thinking that the webdesign can not be what a desktop or laptop is normally bigger that a mobile web site ?

thats not true at all
If you want a normal web that send mobile visitors to a mobile version you can do a css file that switches on a viewport directive



U_S_AAuthor Commented:

I have a site -

users that normally go to from their desktop have been bypassing my regular site and going to the mobile site ,, from their desktop

by doing this ,, they are also bypassing most of my adsense links

that is why I want to have the mobile users only accessing the mobile version of the site,, and not letting the desktop users to have access to the mobile version.
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.


and if you think about it do a similat thing on

as I dont think you can do it at the dns system as that would be better mind you are you running dns local? As that might also work thinking about it
Ray PaseurCommented:
You can detect the browser in PHP.  It is usually found in $_SERVER["HTTP_USER_AGENT"] and looks something like Mozilla/5.0 (Windows NT 6.1; rv:8.0.1) Gecko/20100101 Firefox/8.0.1.

Check these links for more. (look for "browscap").

To see what a mobile browser looks like, install this script and visit the site from your i-phone

<?php phpinfo();

Once you have detected a stationary browser in the mobile scripts, you can issue this command to redirect

<?php header("Location: path/to/stationary/site/");

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
U_S_AAuthor Commented:
These are all good answers.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.