tags:

views:

321

answers:

6

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?

+1  A: 

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.

Residuum
+1  A: 

take a look at this script:

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

lets you specify different redirects depending on browser.

Josh

Josh
A: 

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.

Barry Gallagher
+3  A: 

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.

Roberto Teixeira
A: 

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]
Uqqeli
A: 

If you are looking for ASP.NET solution use http://51degrees.codeplex.com/. It is an ASP.NET open source module which detects mobile devices and provides auto redirection to mobile optimized pages when request is coming from mobile device. It makes use of WURFL mobile device database. For redirection there is no need to modify existing ASP.NET web application pages.

Amit Patel