#!/usr/bin/perl
$user_agent = $ENV{'HTTP_USER_AGENT'};

if ($user_agent =~ /Android/i && $user_agent =~ /Mobile/i){
print "Location: ./index.html\n\n"; # Android mobile

}elsif ($user_agent =~ /Android/i ){
print "Location: ./index.html\n\n"; # Android Tablet

}elsif ($user_agent =~ /iPhone/i || 
        $user_agent =~ /iPod/i || 
        $user_agent =~ /dream/i || 
        $user_agent =~ /CUPCAKE/i || 
        $user_agent =~ /BlackBerry/i || 
        $user_agent =~ /webOS/i || 
        $user_agent =~ /incognito/i || 
        $user_agent =~ /webmate/i
        ){
print "Location: ./index.html\n\n"; # smartphone

}elsif($user_agent =~ /UP\.Browser/i || 
        $user_agent =~ /UPSim/ || 
        $user_agent =~ /KDDI/ || 
        $user_agent =~ /DoCoMo/i || 
        $user_agent =~ /J-PHONE/ || 
        $user_agent =~ /Vodafone/ || 
        $user_agent =~ /SoftBank/ || 
        $user_agent =~ /Googlebot-Mobile/ || 
        $user_agent =~ /Y!J/){
print "Location: ./index_m.html\n\n"; # mobile

}else{

print "Location: ./index.html\n\n"; # PC
}

exit;
