WAP for BlackBerry on Apache
This is slightly off the topic, but I will figure out a way to tie it in.
You have a webhost with Apache and allowing .htaccess files... how can I make WAP friendly pages to display?
1. Create a .htaccess file and upload it to your WAP subdomain or directory!
This should handle all the file types listed. The adp will handle ringtones converted from mp3 to adp for blackberry. Download and save as a ringtone!
jar and jad will handle install java apps. Be sure to upload the .cod file also.
wml, wmlc, wbmp, wmls, wmlsc, xhtml are the pages for your WAP browser.
2. I want to redirect depending on if it is a WAP browser or a "real" browser.
Good News, here is some PHP code that does it written by Anurag Singh:
Now you can host your WAP site on the same server as your normal website with no problems! (As long as your webhost allows .htaccess files of this nature)
You have a webhost with Apache and allowing .htaccess files... how can I make WAP friendly pages to display?
1. Create a .htaccess file and upload it to your WAP subdomain or directory!
Options +Indexes
AddType audio/adpcm adp
AddType text/vnd.sun.j2me.app-descriptor jad
AddType application/java-archive jar
AddType text/vnd.wap.wml wml
AddType application/vnd.wap.wmlc wmlc
AddType image/vnd.wap.wbmp wbmp
AddType text/vnd.wap.wmlscript wmls
AddType application/vnd.wap.wmlscriptc wmlsc
AddType application/vnd.wap.xhtml+xml xhtml
This should handle all the file types listed. The adp will handle ringtones converted from mp3 to adp for blackberry. Download and save as a ringtone!
jar and jad will handle install java apps. Be sure to upload the .cod file also.
wml, wmlc, wbmp, wmls, wmlsc, xhtml are the pages for your WAP browser.
2. I want to redirect depending on if it is a WAP browser or a "real" browser.
Good News, here is some PHP code that does it written by Anurag Singh:
//Description
//Do not remove the below code. This will lead to violation of Terms Of Use
/****************************************************************************
This script is written by Anurag Singh
Title: Wap Redirect
Version: 1.0
Email: tom.anu007@gmail.com,
Homepage: http://tom.anu007.googlepages.com/wapredirect
Special thanks to Harald Hope, Website: http://techpatterns.com/
And also to Joseph George Jacobs , Email joe@spitzbucket.com
****************************************************************************/
//Configuration
global $userBrowser;
// Your wapsite
//enter the link you want user to be redirected in case of WML browser
$wmllink = "http://backalley.net/wap/wap.xhtml";
// Your website
//enter the link you want user to be redirected in case of PC browser
$htmllink = "http://backalley.net/wap/pc.html";
//There is no need to edit any information from this point on
//however in case if you want to contribute please do so
//please be sure to let me know about the changes
//Detect the browser
$userBrowser = $_SERVER['HTTP_USER_AGENT'];
//Remove the below // qutoes.
//It helps to check if there is any error when editing
//If everything is all right it will display the browser information
//please remember to put // back after testing or no redirection will occur
//echo $userBrowser;
//Check for Windows CE
if(stristr($userBrowser, 'Windows CE'))
{
$ub = "WML";
}
//Check for Mozilla
elseif(stristr($userBrowser, 'Mozilla'))
{
$ub="PC";
}
//Check for Mozilla
elseif(stristr($userBrowser, 'gecko'))
{
$ub="PC";
}
//Check for opera
elseif(stristr($userBrowser, 'opera'))
{
$ub="PC";
}
//Check for omniweb
elseif(stristr($userBrowser, 'omniweb'))
{
$ub="PC";
}
//Check for msie
elseif(stristr($userBrowser, 'msie'))
{
$ub="PC";
}
//Check for konqueror
elseif(stristr($userBrowser, 'konqueror'))
{
$ub="PC";
}
//Check for safari
elseif(stristr($userBrowser, 'safari'))
{
$ub="PC";
}
//Check for netpositive
elseif(stristr($userBrowser, 'netpositive'))
{
$ub="PC";
}
//Check for lynx
elseif(stristr($userBrowser, 'lynx'))
{
$ub="PC";
}
//Check for elinks
elseif(stristr($userBrowser, 'elinks'))
{
$ub="PC";
}
//Check for Mozilla
elseif(stristr($userBrowser, 'Mozilla'))
{
$ub="PC";
}
//Check for links
elseif(stristr($userBrowser, 'links'))
{
$ub="PC";
}
//Check for w3m
elseif(stristr($userBrowser, 'w3m'))
{
$ub="PC";
}
//Check for webtv
elseif(stristr($userBrowser, 'webtv'))
{
$ub="PC";
}
//Check for amaya
elseif(stristr($userBrowser, 'amaya'))
{
$ub="PC";
}
//Check for dillo
elseif(stristr($userBrowser, 'dillo'))
{
$ub="PC";
}
//Check for ibrowse
elseif(stristr($userBrowser, 'ibrowse'))
{
$ub="PC";
}
//Check for icab
elseif(stristr($userBrowser, 'icab'))
{
$ub="PC";
}
//Check for crazy browser
elseif(stristr($userBrowser, 'crazy browser'))
{
$ub="PC";
}
//Check for IE
elseif(stristr($userBrowser, 'internet explorer'))
{
$ub="PC";
}
//If it's not any of the above browsers
//Then it gotta be a WML or very unpopular browser
else
{
$ub="WML";
}
//Code for redirecting based upon the results
if($ub == "PC") {
header("Location: ".$htmllink);
exit;
}
else
{
header("Location: ".$wmllink);
exit;
}
?>
Now you can host your WAP site on the same server as your normal website with no problems! (As long as your webhost allows .htaccess files of this nature)
Labels: apache, blackberry, WAP, web server
