Say I've got two distinct domains:
1) http://sub.test.org
2) http://m.sub.test.org
for my web site.
I want domain n.1 to be associated to the full-version of my website (intended to be mainly visited by desktop user agents) and domain n.2 to be associated to its mobile-version (intended to be mainly visited by mobile user agents).
Both of the versions reside on an external host which runs an instance of Apache webserver I can't control directly, but I am able to post .htaccess
files and therefore I want them to control domain redirecting stuff (I don't want to use Javascript neither PHP server-side logic)
The directory structure on the external host is, say:
directory / --> contains full-version website's pages and resources
(index.html is the entry-point)
directory /mobile --> contains full-version website's pages and resources
(index.html is the entry-point)
and the mappings are:
http://sub.test.org -> /index.html
http://m.sub.test.org -> /mobile/index.html
Now, my desired scenarios are as follows:
A) When user asks for URL http://sub.test.org
:
http://m.sub.test.org/*
(this means: if user is currently into the mobile-version) THEN serve page http://sub.test.org/index.html
http://m.sub.test.org
http://sub.test.org/index.html
B) When user asks for URL http://m.sub.test.org
- no matter what the user agent is - user should be redirected to URL http://sub.test.org
.
My questions:
.htaccess
file?Any help/code hint would be really appreciated, because I have really a few experience with Apache .htaccess
files and regexps!