As some of you know for some time I have been trying to figure out how to redirect mobile users from my main site to my phpbb forum without the joomla/jfusion intergration shizzle.
Anyhow I figured it out! But have a hit a problem..
Ok lets start from the beginning I have found a script and have been testing it here -
www.themidwiferysanctuary.com/mobiletest.php
If you click on the above link on a desktop browser it should take you to my normal site but if you access it through a mobile device e.g. iphone it should take you too a blue looking mobile version.
1st off can you try it please.
As far as I can tell it works so obviously the code is no use to me in mobiletest.php as well thats not even a page. so I want the code to be in my main index page of my website.
So this is the code -
PHP Code:
function is_mobile(){
$regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|";
$regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|";
$regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|";
$regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|";
$regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220";
$regex_match.=")/i";
return isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']) or preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT']));
}
if(is_mobile()) {
//it's a mobile browser, do something
header("Location: http://www.themidwiferysanctuary.com/phpBB");
} else {
//it's not a mobile browser, do something else
header("Location: http://www.themidwiferysanctuary.com");
}
So I stuck that in my main index page, pretty much anywhere I don't know if it matters where.
Then I tried accessing my main url
www.themidwiferysanctuary.com from my iphone (it should redirect me to the mobile site) which it did! YAY!
But if I tried to access the main site via a desktop browser, firefox said that it was redirecting in a way that was never going to complete (or something along those lines) and the page just timed out...
So now I don't know what to do!