[thelist] configuring a subdomain

Anthony Baratta Anthony at Baratta.com
Thu Aug 29 16:05:01 CDT 2002


At 12:52 PM 8/29/2002, noah wrote:

>I have a domain configured and working as a virtual host in Apache. I'd
>like to configure a subdomain within that domain to point to a specific
>directory in that domain. For example, I have:
>
>http://example.com/
>
>and I'd like to set up:
>
>http://subdomain.example.com/ and have it point to
>http://example.com/subdomain/

First off, do you want subdomian.example.com to "serve content" from
example.com/subdomain, or do you want subdomain.example.com to "redirect"
to example.com/subdomain ???

Either way - this is how I would set it up:

_DNS_

<snip other DNS settings>

; Mail Server
@                       IN      MX      10      mail.example.com.
; ***********************************************************************
;Basic Server Names
@                       IN      A               123.123.123.123
mail                    IN      A               123.123.123.123
www                     IN      A               123.123.123.123
ns                      IN      A               123.123.123.123
ftp                     IN      A               123.123.123.123
; Sub Domains
subdomain               IN      A               123.123.123.123
; Catch-All
*                       IN      A               123.123.123.123


_Apache_

<VirtualHost 123.123.123.123:80>
         ServerAdmin root at example.com
         ServerName www.example.com
         ServerAlias example.com
         DocumentRoot /web/sites/example.com/
         ScriptAlias /cgi-bin/ "/web/sites/example.com/cgi-bin/"
         ErrorLog /web/apache/logs/example.com-error.log
         CustomLog /web/apache/logs/example.com-access.log common
</VirtualHost>

<VirtualHost 123.123.123.123:80>
         ServerAdmin root at example.com
         ServerName subdomain.example.com
# Will Serve Content from the example.com/subdomain directory
         DocumentRoot /web/sites/example.com/subdomain
# Use a .htacces file in target directory to redirect browser
         DocumentRoot /web/sites/example.com-subdomain/
         ScriptAlias /cgi-bin/ "/web/sites/example.com-subdomain/cgi-bin/"
         ErrorLog /web/apache/logs/example.com-subdomain-error.log
         CustomLog /web/apache/logs/example.com-subdomain-access.log common
</VirtualHost>

.htaccess

Redirect / http://www.example.com/subdomain


Hope this helps.
--
Anthony Baratta
President
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."




More information about the thelist mailing list