• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Virtual Subdomais with www

I have a domain www.example.com and I want to add a subdomain www.test.example.com.

It just works if I add it like test.example.com
What should I do to be able to make it work as www.test.example.com ?

I am using Virtual Domains in Apache.

Need your help!
Deco
0
Deco
Asked:
Deco
  • 2
2 Solutions
 
pjedmondCommented:
OK - using the script below or similar....after thatall you need to do is ensure that the DNS is set up correctly.

i.e:

ping www.example.com
ping www.test.example.com
ping test.example.com

As long as the DNS resolves correctly, then the below (or similar) will give you what you want:)

--------------------------------------X8-------------

NameVirtualHost *:80   # Any port 80 connection on any interface is virtual host

# Virtual host www.example.com
<VirtualHost _default_:80>     # On default interface - assume one:)
DocumentRoot /var/www/html/www/
       Options ExecCGI
       ServerName www.example.com
       ScriptAlias /cgi-bin/ /var/www/cgi-bin/
</VirtualHost>

# Virtual host www.test.example.com
<VirtualHost _default_:80>
       DocumentRoot /var/www/html/test/
       ServerName www.test.example.com
</VirtualHost>

# Virtual host test.example.com
<VirtualHost _default_:80>
       DocumentRoot /var/www/html/test2/
       ServerName test.example.com
       DirectoryIndex index.htm
</VirtualHost>
--------------------------------------X8-------------

Hope that helps:)
0
 
PCBackupCommented:
pjedmond is correct with the explanation of the virtual hosting setup in Apache, but I think the confusion here has to do with domains and the DNS setup for the named addresses within a domain.

I think it is important to point out that www.example.com is not a domain.  The domain is example.com instead.  So, www.example.com simply points to an address for that domain.  You can create any number of named addresses for your example.com domain with any number of prefixes.  You are only limited by how crazy you want to drive the visitor to the website entering in all those characters.  

Also, www.test.example.com is NOT a subdomain of www.example.com.  www.test.example.com IS a subdomain of test.example.com.  Just remember that web addressing starts at the right end of the address name and parses to the left to reach the actual address.

You might just want the second website address to be test.example.com.  There is nothing that says a website has to start with www to be valid.  This is just standard practice for the primary website of a domain.

Does that help explain things any clearer?

Gene
0
 
DecoAuthor Commented:
Another thing!
for each virtual domain I create, do i have to add it into DNS?
0
 
PCBackupCommented:
That's how I do it.  It might be possible to create subdomains of your primary site in the web server setup, but I find it easiest to create a pointer to each website virtual domain.  If you're running your own DNS, it's really the easiest way to approach it.

Gene
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now