Can a username redirect to a subdomain?
September 2, 2006 9:02 AM   Subscribe

How would I setup a password-protected subdomain where the username is the subdomain? My levels of incompetence will be further explained, as there is

I would like to have a series of subdomains setup for password protection, with the username also being the name of the subdomain.

How can I setup a single login screen that takes a given input of username/password and (if a valid username/password combination) redirects to the address http://username.domain.com/?

For what it's worth, I will be using a LAMP-style server and have the ability (but not necessarily the skill) to write .htaccess files.
posted by jmevius to Computers & Internet (3 answers total)
 
This would be pretty easy, but requires the following:

- access to the DNS server for your domain, so that you can set up all the various valid hostnames (www.example.com, jack.example.com, jill.example.com, etc.) to point to your server;
- access to the webserver config on your box, so you can have the webserver respond to any given *.example.com hostname (or specifically, the example.com hostnames that you wish to be valid);
- a way to define which usernames and passwords are valid which can be accessed programmatically (e.g., an array in your page that serves the login script, a database that your page can query, whatever).

Then, it just takes writing the login page, which should have a form for the username and password, and on submission, should check those for validity and then do the direction. If you say you're using LAMP, then this is trivial to do in PHP.
posted by delfuego at 11:03 AM on September 2, 2006


Response by poster: To respond:

- I have access to the server for the domain and the ability to setup the names (jack.example.com, jill.example.com, etc.).
- I think I also have the ability to configure the webserver to respond to a given *.example.com name
- I have no idea how to accomplish this whatsoever. Searching hasn't yielded any positive results as of yet. Is this type of login/verification have some standard nomenclature that I could call it for searching?

You'll have to forgive all of the ignorance here...
posted by jmevius at 5:40 PM on September 2, 2006


I think you're getting confused because you're seeing the two things as fundamentally connected.

Is it possible to do logins using PHP? Yes.

Is it possible to have subdomains with pretty much any name you like? Yes.

But you're seeing some hard and fast connection between the two things when in fact they're completely arbitrary.

You can use a username-and-password system to log in to anything, and redirect the user anywhere.

You can put anything you like on a subdomain, including code which rejects people who aren't logged in.

The fact that you want the username to match the subdomain is irrelevant in terms of the code. It just happens to be the way you're going to implement the two things.
posted by AmbroseChapel at 10:23 PM on September 2, 2006


« Older How bad a shape is my hard disk in?   |   How does thinking of dreams cause sleepiness? Newer »
This thread is closed to new comments.