Creating a sub domain

prism4

Verified User
Joined
Nov 22, 2003
Messages
21
I am trying to create a subdomain that will point to a new URL address.

For example our main domain is www.telforceusa.com

What I want to do is create a new subdomain such as www.new.telforceusa.com and have it go to a diferrent url address. I know it can be done and I did it before but I cant seem to duplicate the process Can anyone help.

Thanks

Michael
 
I'm not sure if this can be done through DirectAdmin or not, I haven't touched that section in awhile.
You could create an Alias or redirect in the httpd.conf file directly.
Or you can actually create the subdomain and use a redirect in an html file or a .htaccess file.

Searching for "redirect subdomain" might return some helpful threads.
 
prism4 said:
I am trying to create a subdomain that will point to a new URL address.

For example our main domain is www.telforceusa.com

What I want to do is create a new subdomain such as www.new.telforceusa.com and have it go to a diferrent url address. I know it can be done and I did it before but I cant seem to duplicate the process Can anyone help.

Thanks

Michael
Ok, do you want www.new.telforceusa.com to point to telforceusa.com?
 
no i want to be able to have the new sub address go to a new specific page or website.
 
To do what you want to do you don't create the subdomain as a subdomain in your DA account.

If you're hosting the subdomain on the same server, then you need to set it up as a domain as opposed to as a subdomain.

If it's on another server you don't do anything special on DirectAdmin...

However, the subdomain must have an A record pointing to the IP# of the server where it's hosted (whether or not it's the same server).

So you should change the zone file (wherever you host DNS for the main domain) to have an A record for the subdomain pointing to the IP# of the server where you host the subdomian.

That should do it.

Jeff
 
Here's what I do:

1) Create a wildcard DNS to resolve all subdomains:
User Level -> DNS Control -> add an A record:

* A 1.2.3.4

where 1.2.3.4 is your websites IP adresss.

2) Tell apace how to handle the wildcard:
Admin Level -> Custom httpd.conf configuration -> domain.com. Insert the following into the top text area:

code:ServerAlias *.|DOMAIN|

then click "Save".

3) In index.php on the "main" page of the site (www.foo.com) -
PHP:
<?
preg_match("/([^\.\/]+)\.([^\.\/]+\.[^\.\/]+)$/",strtolower($_SERVER["HTTP_HOST"]),$host);

//If they forgot to type in a host...

if ($host[1]=="") {
        header ("LOCATION:http://www.foo.com");
}
if ($host[1] !="www") {
header ("LOCATION:http://www.foo.com/$host[1]");
}
?>

Try something along those lines, if you're just wanting to redirect to a page within your site.
 
Last edited:
actually I am trying to redirect to another website not on our server
 
Back
Top