You can do it with PHP and the HTTP User Agent:
function find_mobile_browser()
{
if(preg_match('/(alcatel|android|blackberry|benq|cell|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|midp|mini|mobi|motorola|nokia|palm|panasonic|philips|phone|sagem|sharp|smartphone|sony|symbian|t-mobile|up\.browser|up\.link|vodafone|wap|wireless|xda|zte)/i', $_SERVER['HTTP_USER_AGENT']))
{
return true;
}
return false;
}
Call this Function in the beginning of a code and it returns True
if your user uses a Mobile User Agent. Ant then you can include the actual site. The if
-Block could look like this: (Im not sure about the Include/Requested URI at the Moment)
if($_SERVER['REQUESTED_URI'] == ''){
$request = index.html;
}
else{
$request = $_SERVER['REQUESTED_URI'];
}
if(find_mobile_browsers()){
include('mobile/'.$request);
}
else{
include('desktop/'.$request;
}
Be Aware that the User Agent can be changed or doesn't get send to you but in this Case it would just return the Desktop Version.
For the .htaccess
see this site: http://jrgns.net/redirect_request_to_index/