Kernel_Killer
July 4th, 2006, 22:00
So, I set up a WAP virtual server on one of my Apache servers, and all seems well. I'm trying to make it to where phones that support html go to the html page, and phones that can only view WML pages are redirected to the wml page. Unfortunatly my phone is a html based phone, and does not do WML (yeah, wtf??). I'm using a online-emulator (http://www.wapsilon.com/) to test the WML page.

If you go to the site with the emulator on the root of the site, you get:

Wrong mime-type, I got text/html, but I want text/vnd.wap.wml.
This error occurs when you request a page that is not a WAP page, or when the webserver isn't set up correctly for hosting WAP sites

Now, if you browse to the domain with index.wml at the end, the site shows fine. So, a redirect issue, right?

Here is what Apache's error.log shows:

[Tue Jul 04 21:41:06 2006] [notice] SIGHUP received. Attempting to restart
PHP Warning: mime_magic: type regex\t\tBEGIN[[:space:]]*[{]\tapplication/x-awk invalid in Unknown on line 0
[Tue Jul 04 21:41:06 2006] [notice] Apache/2.0.55 (Debian) PHP/4.4.2-1.1 configured -- resuming normal operations

I had to do the page with a PHP header because for some reason the XML header always makes the emulator error.

This is what I've added to Apache in the apache2.conf to redirect:

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!!
RewriteRule ^[\./](.*)$ /welcome_wap_user.wml [L]

Mod_rewrite is also enabled, and shown in the mods-enabled directory. Any ideas? The site is http://blvddrin.com.

Just in case, here is the page:

<?php

# Send the header information<br>
header("Content-type: text/vnd.wap.wml");

?>

<wml>
<card id="index" title="Blvd Drin">
<p>
Now Playing<br/>
<b>Listing</b>
</p>
</card>
<card id="movie1" title="Test">
<p>
test
</p>
</card>

<card id="movie2" title="test2">
<p>
test2
</p>
</card>
</wml>

frisco
July 8th, 2006, 22:18
Right now i get a 404 if i go to http://blvddrin.com/welcome_wap_user.wml in firefox. Is this page currently not there? Was it there before?

Kernel_Killer
July 9th, 2006, 01:32
Thanks. I changed the redirect to index.wml. I don't know how I missed that. Just another mindless KK moment. Can you test it to double check when you get a chance?

frisco
July 9th, 2006, 12:13
Going directly to index.wml works, but it doesnt look like i'm getting redirected to the wap page. Just in case, i tried running this:
wget -U wap -S http://blvddrin.com/

which should also be caught by the redirect commands (and does work on other wap-enabled sites). May need to see more of your httpd.conf - do you have a LoadModule statement in there for mod_rewrite (LoadModule rewrite_module path/to/mod_rewrite.so), or was it compiled in (will be listed if you run `httpd -l`)?

Kernel_Killer
July 9th, 2006, 19:09
Ok, well Apache doesn't list it with a -l, but a2enmod says it is. Since this is a Debian server (couldn't find cheap co-lo servers that were BSD :( ), I'll Google the rest. Thanks a bunch Frisco.

Kernel_Killer
July 19th, 2006, 01:40
Ok, I fixed it finally. Apache2 is what caught me. It was quite vague in every article as to where to put the RewriteRule. I was working on another site to have a redirect for a site to redirect to another site, and then by a slight chance found in the Apache docs that a bunch of crap could be put in between the VirtualHost tags. So I put my rewrite rules after the Virtual Server info, and right before the closing VirtualHost, ran 'apache2ctl graceful', and all is good now. :biggrin:

It use to be, you could add a Directory block, and add it, or in the httpd.conf, and be all good. Having to migrate to 2.x has been odd, but lots of benefits. For instance, having a file for each site is quite nice.