Forum Moderators: phranque
I added the subdomain via WHM DNS setting, not via cPanel's add subdomain option.
But "A" is for IP only and I want it to be redirected to another subdomain, not the /public_html/ (where the IP directs).
I tried another option, by creating Virtual SubDomains via httpd.conf
It's working alright, but my main problem is, it is loading a "cPanel" page instead of reading the subdomain it was supposed to remapped to.
Instead of showing the contents (or site) of
subdomain.domain.tld
it instead loads up a cPanel page.
I don't get where or what I did wrong, or if I'm approaching the whole idea wrongly.
Basically what I want is to remap a subdomain to another subdomain since my application needs to read the actual URL used so it can load up a different page.
I'm lost...
Thank you very much.
Btw, here's what I added in my httpd.conf:
<VirtualHost IP-HERE>
ServerAlias *.domain.tld
ServerAdmin email here
DocumentRoot /home/***/public_html/subdomain_to_be_redirected_to
User ***
Group ***
ServerName *.domain.tld
</VirtualHost>
Though I prefer the first one I mentioned or a more simpler one. I want to avoid editing httpd.conf if there's another and/or better way.
Thanks!
[edited by: Laibcoms at 11:52 am (utc) on Jan. 9, 2007]
DocumentRoot /home/***/public_html/subdomain_to_be_redirected_to
Outside the server, on the Web, we have domains, subdomains and URL-paths. Once those requests land on our server, however, we have only direectories and files. So domains, subdomains, and URL-paths "disappear" conceptually at the boundary between the Web and the server's files. That is in fact the main job of a server application like Apache, to translate URLs to filepaths and deliver the requested content from the file(s) associated with the requested URL.
So the pseudo-code should read
DocumentRoot /home/***/public_html/subdirectory_path_for_this_subdomain's_documents
I note that you have both the ServerAlias and ServerName in this container defined identically. That's neither necessary nor desirable. Also, make sure your <VirtualHost> containers are ordered from most-specific to least-specific in httpd.conf. You'll want to define the specific subdomain exactly in the first --or in one of the first-- VirtualHost containers, and the "*.example.com" catch-all should be defined last.
Alternatively, you can point all subdomains to the same DocumentRoot, and use mod_rewrite in httpd.conf or in .htaccess to sort different subdomain requests into different subdirectories.
Like Windows, one of the problems with setting up a server is that there are many ways to do things...
Jim