CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Creating subdomains

 



patk
Deleted

Feb 11, 2000, 5:44 PM

Post #1 of 3 (1923 views)
Creating subdomains Can't Post

Hello! Thanks for the database
help, I think I'll stick to
flat-file though. Anyway, my new
topic is over subdomains. My server
is a UNIX machine, and I am trying
to make a new subdomain on my domain,
(http://subdomain.mydomain.zzz)
how it works is that a sub directory
on the main directory (/path/to/main/subdir/)
reads as the same as a subdomain
so if I make a directory using perl, eq
mkdir(subdir, 0755); will make a directory
but how do I get to read as a subdomain?
I know I need to submit some dns things or something too, but can I do with perl as well? Also I know that "Wild Cards" is not enabled but I may be able to, but does it have to be? Thanks!


Red Dragon
Deleted

Feb 11, 2000, 8:24 PM

Post #2 of 3 (1923 views)
Re: Creating subdomains [In reply to] Can't Post

The easiest way to do this on an automated basis is to redirect subdomains like fred.domain.com to www.domain.com/fred
I believe this is what you are looking for.
Use an index.cgi in your main directory that test the enviromental value of HTTP_HOST for www.domain.com and write to the location bar www.domain.com/index.html (or whatever the main file for the actual site is) if its not www then have it pull the prefix from the variable and print www.domain.com/prefix to the location bar.

something like this
if($ENV{'HTTP_HOST'} eq "www.domain.com")
{
print "Location: http://www.domain.com/index.html\n\n";
}
else
{
$pre=$ENV{'HTTP_HOST'};
$pre=~s/(\w+)\..*/$1/;
print "Location: http://www.domain.com/$pre\n\n";
}


[This message has been edited by Red Dragon (edited 02-11-2000).]


Red Dragon
Deleted

Feb 11, 2000, 8:31 PM

Post #3 of 3 (1923 views)
Re: Creating subdomains [In reply to] Can't Post

Almost forgot.

You will need to add a wildcard in your name server.

if its a bind name server then
*.domain.com. IN CNAME www.domain.com.
should do the trick

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives