Question

I have a website with the following files in the root folder: index.wml index.php

How do I get it to open index.php if you are accessing via non-wap browsers, but open index.wml automatically when it is a wap browser. I suspect something must go in the .htaccess file?

Was it helpful?

Solution

take a look at this script:

http://tom.anu007.googlepages.com/wapredirect

lets you specify different redirects depending on browser.

Josh

OTHER TIPS

I would suggest that you use the Mobile Device Browser File. It's a database containing capability information for tons of known devices. Even though it was created to be used in ASP.NET applications, it's an XML file and thus you can use it from PHP as well (take a look at the file schema).

I greatly recommend that you use capabilities to decide how to send content to the devices, instead of any simple "if not desktop and not laptop then send_wap()". Take a look at the list of capabilities included.

You could accomplish that in index.php with user agent switching and the redirecting the wap browsers to index.wml, but I have no idea what wap browsers report in their user agent string.

If it's just one page you want to render in a different format (WAP and PHP), try adding a "handheld" stylesheet to reformat the page and/or hide elements & divs for WAP browsers.

<link rel="stylesheet" type="text/css" media="handheld" href="wap.css"> 

Otherwise you will have to use a redirect script such as the one Josh linked.

This could be done with mod_rewrite.

RewriteCond %{HTTP_ACCEPT} application/vnd\.wap\.xhtml\+xml [OR]
RewriteCond %{HTTP_ACCEPT} text/vnd\.wap\.wml
RewriteRule ^index\.php http://host.com/index.wml [L,QSA,R]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top