Solved

How to create/use a virtual subdomain

Posted on 2004-03-22
4
923 Views
Last Modified: 2007-12-19
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.
0
Comment
Question by:m8rix
  • 2
4 Comments
 

Accepted Solution

by:
Pentabyte earned 250 total points
ID: 10655776
> 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
 
LVL 7

Assisted Solution

by:Saoi
Saoi earned 250 total points
ID: 10656949
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
 
LVL 10

Author Comment

by:m8rix
ID: 10661825
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
 
LVL 7

Assisted Solution

by:Saoi
Saoi earned 250 total points
ID: 10665781
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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now