|
Introduction to WML, Apache, and PHP
Setting up Apache
Ok, now the fun part. In order for apache to catch what a wireless device visits your
server, you need to set up your httpd.conf ( my file is located in /etc/httpd/conf/ ) file, I am using PHP3 so all changes are made accordingly. Before you start you may want
to make a backup copy of your httpd.conf file, just in case :)
Step 1: First, we need to use the AddType function to add a new mime
type. You need to go to to the script where you define php. It looks something like below:
<IfModule mod_php3.c> AddType application/x-httpd-php3 .php3 .php .phtml AddType application/x-httpd-php3-source .phps </IfModule>
Needs to be changed to:
<IfModule mod_php3.c> AddType application/x-httpd-php3 .php3 .php .phtml .wml AddType application/x-httpd-php3-source .phps </IfModule>
This will use the php compiler on all .wml pages it encounters.
Step 2: Uncomment the apache Load Module and Add Module
change:
#LoadModule rewrite_module modules/mod_rewrite.so #AddModule mod_rewrite.c
to:
LoadModule rewrite_module modules/mod_rewrite.so AddModule mod_rewrite.c
Step 3: We'll use apache mod_rewrite module (only available in
version 1.2+ ). Using this, you can rewite requested URL's on the fly, as certain
conditions are met. You need to place this code snipplet at the bottom of the page.
RewriteEngine On
# Catch most WAP browsers
RewriteCond %{HTTP_ACCEPT} text/vnd\.wap\.wml [OR]
# WinWAP, WAPjag
RewriteCond %{HTTP_USER_AGENT} wap [OR]
#Nokia emulators (sdk)
RewriteCond %{HTTP_USER_AGENT} 7110
# Rewrite to where your wireless page is located
RewriteRule ^[\./](.*)$ /home/mydirectory/wireless/home.wml [L]
Now, you will need to restart the apache server.
Creating your first WML/PHP wireless page
Ok, now that we have everything set up, lets create our first page. In order for a wireless
device to access a page compiled using php, you need to send the correct header information. 

