Thursday, October 19, 2006

Nokia6100 and the Unknown file type

It would appear that the earlier Nokia versions, i.e. my 6100 are not so clever when it comes to detecting what the Web server is sending it. If you give it a .php file then even if Apache is telling you it's of type "text/vnd.wap.wml" then it will error with a cryptic "Unknown file type" message. You need to send .wml files for the phone to be happy.

The work around for this issue is not too complex:

In the .htaccess file you need to add a few lines. The first adds an extra option for the index file.

DirectoryIndex index.wml index.php index.html index.htm

Then we add some code to tell apache to use php to process the index.wml


AddType text/vnd.wap.wml .wml
AddHandler application/x-httpd-php .wml


Finally in the .wml file we put the relavent php code to generate the .wml code for the WAP clients.

2 comments:

Unknown said...

Can you enlighten me on why the .htaccess file is necessary for this and what it's purpose is?

FleaCircusDirector said...

The commands in the htaccess file make the Apache webserver process .wml files as if they are .php files. This allows us to php code in the .wml files. Earlier phones are not clever enough to use the mime file type and rely on the file's extention to determine if it is wml or not hence we can't server .php files to such a phone.