How to create/use a virtual subdomain

Hi, I am new to PHP. In fact I have managed to avoid using it at all.
I would like to know how to do something like what these guys have done here:
http://santa.clause.swellserver.com/news/top_stories/auto80.php
The sub domains can be changed to anything at all, and the page picks them up.

The reason I would like to know this is that my host charges me for every new subdomain I want to create.

I would like to be able to use this method which is more of a "virtual" subdomain.

The only thing is I would still like to be using ASP coding on the same page, but even still, if you can answer the original question of "how it is done" you can share the points.
LVL 10
m8rixAsked:
Who is Participating?
 
PentabyteConnect With a Mentor Commented:
> The reason I would like to know this is that my host charges me for every new subdomain I
> want to create.

Then you need to change your Webhoster!
They only charge money, because they spend working time for typing in your subdomains. They just don't allow you access to their interface.

Solution A)
Pay for ONE wildcard subdomain: *.yourdomain.com
... and every request will be forwarded to your html-directory

Solution B)
Choose a webhoster with some kind of domain-management via webinterface.
My webhoster provides me with Confixx, a tool to configure email-adresses, pop-accounts, subdomains, mysql-databases, etc.
0
 
SaoiConnect With a Mentor Commented:
You might want to consider transferring control of your domain to ZoneEdit (http://www.zoneedit.com/). Its free, it allows unlimited sub-domains, redirections to each domain, MX records - basically full control over your domain. You can pay for some extra services, but its not really necessary. I use ZoneEdit to look after my companies domains, we have never had a problem with them in 3 years.

Depending on your host configuration you may have to negotiate with them about how the server handles requests - ie if the host name is used to redirect to a virtual server (most likely) rather than having a specific IP for your server, they may not like it. But there are ways around that also.

Hope this helps
0
 
m8rixAuthor Commented:
Thank-you to both Pentabyte and Saoi for your comments and sugestions. I am asking my host if it is possible to pay for ONE wildcard subdomain: *.yourdomain.com and suggested by Pentabyte.

I can't afford to change hosts at this stage because of the down time in between. I would have to talk to my clients and let them know what I am doing first. Besides I have been using my host for some time, and until now they have been pretty good.

But getting back to the topic. Does anyone know how the virtual subdomain in the following link is captured?
http://any.subdomain.swellserver.com/news/top_stories/auto80.php
http://change.here.swellserver.com/news/top_stories/auto80.php
http://differentsubdomain.swellserver.com/news/top_stories/auto80.php

change the subdomains as you please to see what I mean.
0
 
SaoiConnect With a Mentor Commented:
I assume they are simply parsing the URL with a regular expression.

A very simple and unchecked parse...
<?
//Capture the server address:
$server_address = $_SERVER['HTTP_HOST'];
// remove the rest of the domain
$sub_domain = str_replace(".swellserver.com", "", $server_address);
// Sub domain would be:
// "any" or
// "change.here" or
// "differentsubdomain"
// depending on which one you are.
?>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.