I have successfully redirected my page to m.example.com from example.com when i open in mobile environment with this code in functions.php
add_action('template_redirect', 'redirecting_to_mobile_site');
function redirecting_to_mobile_site(){
$requri = $_SERVER['REQUEST_URI'];
if( wp_is_mobile() )
{
$redcont = "http://m.example.com".$requri;
wp_redirect( $redcont, 301 ); exit;
}
}
I also created a sub-domain through WP sub-domain plugin.
But when I click any link from index page it says "This page has redirect loop"
Please advise how to enable sub-domain for internal pages.
Thank you.