Detecting WAP browser

Recently, I have observed that there is a good trend of developing WAP sites in our country. Many young designers are trying to develop WAP sites. Special concentration has seen on ringtone sites, music sites, chat site etc. I have also worked for two WAP sites quite a bit ago. So, today I am posting here a tips of automatically redirecting users to your WAP site.

When does it needed?
Suppose, you have/want two versions of your site. Normal web and wap version. You want that when people browsing your site (let say from mobile, you automatically redirect the user to

Your user will not need to memorize two different domains. Your script will automatically redirect him to respective sites (web or wap). So, less hassle!

Its very simple. Put the following code block at the top of your domains root.


Redirect web and wap users to different location.

header('Location: wap/index.php');
} else {
header('Location: web/index.php');

What it does infact?
The script simply checks whether the browser accepts WML scripts or not. If yes, it may not be an normal browser or it is an WML/WAP browser. So, it redirects the user to pages specially cooked for it.

The drawback is that, if any browser supports both HTML and WML, the browser still is forced to visit the WML pages. But, you can still prevent it with some modification.

  • Nice piece of advice but the article says nothing about what file it should go into?

  • guest

    >>the article says nothing about what file it should go into?

    That’s because that piece of code is a stand-alone code. It depends on nothing else. You can save it as wap_sniffer.php and whenever you need to use it just include it in whatever file YOU need to include it. The use of that file is dependent of your application.