WMLPrograming list

The Wireless FAQ

4.2 What's with the HTTP server MIME types?

When you access a "web page" using a PC based browser, the "web server" tells your PC browser what kind of document it should expect. This is done by using something called MIME-types. The common MIME type for a plain HTML document is "text/html". However, for a WAP micro browser, which cannot read HTML, the MIME type has to be different.

The MIME types for serving WML contents are:

Document type             MIME type                       Typical extension
Plain WML documents       text/vnd.wap.wml                .wml
Wireless Bitmap Images    image/vnd.wap.wbmp              .wbmp
Compiled WML documents    application/vnd.wap.wmlc        .wmlc
WMLScripts                text/vnd.wap.wmlscript          .wmls
Compiled WML Scripts      application/vnd.wap.wmlscriptc  .wmlsc

To add the above MIME types to the Apache HTTP server, here's what you do:

  • Edit the srm.conf file (usually in /etc/httpd/conf)
  • Locate the AddType section, and add the following section to the file:
  • # MIME Types for WAP
    AddType text/vnd.wap.wml .wml
    AddType image/vnd.wap.wbmp .wbmp
    AddType application/vnd.wap.wmlc .wmlc
    AddType text/vnd.wap.wmlscript .wmls
    AddType application/vnd.wap.wmlscriptc .wmlsc
    
  • Save the file and restart the Apache HTTPd.
  • If you do not have control over your Apache server, for instance if you are with an ISP, it is also possible to add a file called .htaccess to each directory where you have placed WML files. When the server reads files from this directory, it will serve them according to the rules in the .htaccess file.

    A typical .htaccess file will look something like this:

    DirectoryIndex  index.wml
    addtype text/vnd.wap.wml wml
    addtype application/vnd.wap.wmlc wmlc
    addtype text/vnd.wap.wmlscript wmls
    addtype application/vnd.wap.wmlscriptc wmlsc
    addtype image/vnd.wap.wbmp wbmp
    

    Note the first line which tells the server that the index file for this directory is called index.wml. Also note that the server must be configured to read these files. In some cases the server is configured to ignore these files for security reasons. Check with your ISP.

    To add the MIME types to a Microsoft IIS server, you need to do the following:

  • On the server console, open the Management console
  • From here you can define the MIME types to either be valid for the entire server or to be valid for separate directories.
  • To add a MIME type to a directory: Right click on the directory in which you want to add the MIME type.
  • Select the HTTP headers tag.
  • Click the File types button at the lower right.
  • Click New type and supply the extension and the content type as listed above.
  • To add a mime type to an entire server; Right click on the server.
  • Click the File types button and follow the instructions above.
  • Click New type and supply the extension and the content type as listed above.
  • For other servers, see the server documentation.

    [ Main ]   [ 04 - Serving WML contents ]