Hi all,
I'm having some problems wrapping my head around the proper solution to this problem and hopefully some of you with more experience can help. If you don't want to read all of this just jump down to the Question heading to get to the point.
Background
First, here's my setup: I have a linode that hosts a couple of domains, say example.com and example.org. Currently both have subdomains of mail.example.com and mail.example.org with CNAME/MX/TXT records for redirecting to Google Apps mail and they have A records for www as well as blank. As well, example.org has a couple other subdomains for non-http purposes, such as ssh.example.org, with A name records for each.
Both have an .htaccess file in the root web directory that consists of, amongst other things, the following code to redirect eg.
www.example.org to example.org:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
So if I go to
www.example.com it changes the address in the bar to example.com.
All of this works fine. However, I want to make some changes and I'm unsure how to proceed.
The Question(s)
What I want is to set it up so that I have all subdomains EXCLUDING mail to be directed to my webserver, with mail still going to Google, and then for anyone coming from any other subdomain (eg.
www.example.org or ssh.example.org or whatever.example.org) to have the address rewritten to example.org. However, to make matters slightly more complicated, on example.com I have a few subdomains that I want to maintain the subdomain in the URL and to redirect the webserver to subdirectories of my site's root directory. So, for example, going to store.example.com should display store.example.com in the address bar but redirect people to example.com/store. Alternatively, if required, I'd certainly be open to having this as a completely different site in apache, whatever's considered best practice.
How to proceed
First, DNS. I believe that I need to add a wildcard (*) record in DNS manager, but should this be an A record or CNAME record? I've been getting conflicting answers, all claiming to be authoritative, from searches. Should I then get rid of the blank entry and the www entry or, conversely, should I add an entry for store? And will this interfere with redirection to Google apps? Everything I've read seems to say that wildcards will only come into play if other records for the subdomain aren't found, but the Wikipedia entry for the topic says that the standard is cryptic and implementations vary, so I'm not sure.
Then there's the matter of how to handle things at the server. Should I have a separate site set up in Apache to catch store.example.com, as I mentioned above, or can I use the .htaccess file to redirect & rewrite things?
Is there anything else that I'm missing?
Sorry about being so long winded, I'm trying to be thorough. Any help that anyone can give is greatly appreciated!
TIA![/b]