I want visitors who are landing on domain.com
from their desktop to be transferred to domain.com/desktop
, all while hiding the "desktop
" part in the URL.
Lastly, if they visit domain.com
from their mobile, I want them to be transferred to domain.com/m
. In this case the "m" can stay I guess, I don't care.
My question is; is the redirection in the .htaccess or in the index.php of my public_html?
EDIT : My /desktop/ directory's htaccess contains this :
RewriteEngine On
RewriteRule ^inc/.*$ index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
The root's .htaccess
contains this :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
RewriteRule !^desktop/ /desktop%{REQUEST_URI} [L]
And my public_html's index.php
contains :
include 'mobile_detect.php';
$detect = new Mobile_Detect();
if ($detect->isMobile()) {
header("Location: http://domain.com/m"); exit;
}else{
header("Location: http://domain.com/desktop"); exit;
}
I feel like I'm doing something very wrong, I just can't figure out what it is. Help?
Thank you very much.