[SOLVED] mod rewrite

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

mod rewrite

Post by tim »

well i'm not really knowledged with this feature.

but what I need to do is create sub-domains from a server off the users login

ie, they register with 'tim' it creates tim.mydomain.com in return.

Can someone please point me in some direction?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

last I saw, that's not mod_rewrite.. that's dynamic DNS handling.. although, it may be possible to do the processing in mod_rewrite through the server variables.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

first you need to make sure all domains point to the right address, zone file likes this:

Code: Select all

* IN A 255.255.255.0
then you tell apache to handle all the domains likes this:

Code: Select all

<VirtualHost 255.255.255.0>
DocumentRoot /home/user/public_html
ServerName www.domain.com
ServerAlias domain.com
ServerAlias *.domain.com
</VirtualHost>
and then a little script to do whatever

Code: Select all

eregi("^([^\.]+)\.",$HTTP_HOST,$args);
$subdomain = $args[1];
if (($subdomain != "www") && ($subdomain!= "DOMAINNAME")) {
  include("file.php");
  exit();
  }
}
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

ty
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Neat script. :)
Post Reply