Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

70 users online



*.domain.com tutorial

*.domain.com tutorial

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 2
BigToach

BigToach

Neversidian
Status: Offline!

*.domain.com tutorial

ok I have seen people bitching about this for a while and I figured that I would mess around with my server until I finally got it. It actually didn't take that long to figure out the basic way. Then I got stupid and forgot that %1 isnt the same as $1 so I was retarded. Anyways this will work with *.domain.com and then you can also check for stuff like *.domain.com* as well

You need to have wildcard DNS on. And you also most likely need to be able to create * ammount of subdomains from your host (many hosts have some way of checking this I think). A bit more about wildcard DNS at the bottom.

OK heres the rewrite code.

Code:

RewriteCond %{HTTP_HOST} ^([^.]+)\.bigtoach\.com$ [NC]
RewriteCond %1 !^www$ [NC]
RewriteRule ^(profile|stats|gallery|work|etc)?/?$ /somefolder/somefile.php?user=%1&type=$1 [L,NC]

Quick examples http://changethisplease.bigtoach.com/ http://somethingelse.bigtoach.com/profile/

A few notes:
1. obviously change bigtoach\.com to what your site is.
2. You can change the rewrite rules on line 3 to whatever.
3. This will not do anything to www
4. Assuming your server is setup correctly it wont effect any of your existing subdomains either.

If you want the rule to go to different pages for different folders (ex: user.domain.com/profile/ goes to /folder/profileindex.php and user.domain.com/stats/ goes to /folder/statsindex.php) you can just substitue the filename with the rewrite (last line from above) like so:

Code:

RewriteRule ^(profile|stats|gallery|work|etc)?/?$ /somefolder/$1index.php?user=%1 [L,NC]

And here is the wildcard dns stuff that I promised, Although the best thing to do would be to just ask your host.

If you dont know how to enable wildcard DNS contact your host, or if you are cool and dont really have a host, contact your DNS host and just ask em to enable wildcard DNS. If you are really crazy and host both, assuming you use BIND just add in *.domain.com.

enjoy kids!

___________________

Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

Last edited by Locke, August 25th, 2005 09:27 PM (Edited 1 times)

johnzer

johnzer

Neverside Newbie
Status: Offline!

Thanks :) Very useful info, will try it out later. Good work BigToach

thefallen

thefallen

PHP Lurver.
Status: Offline!

Yea, thanks alot BT, whenever i see you post i always read it because your a good teacher, learnt alot from you back in the old TF days :D

mcdude

mcdude

Blah
Status: Offline!

Thanks Scott, great info there, someone should make this a sticky!

thefallen

thefallen

PHP Lurver.
Status: Offline!

Yea works a treat :D

Locke

Locke

"Refocusing" My Time
Status: Offline!

This is pretty close to the one we were writing, but excellent work nonetheless Scott.

Time to sticky :D

We'll still release the one we're doing, which may work better for some and worse for others. It'll cover all of the DNS tricks and mod_rewrite tricks we know and are using. In the meantime, Scott rules for producing this and he shall live as a hero. Thanks Scott!

___________________

The Audoptic Weblog. It's where the magic happens.

Last edited by Locke, August 25th, 2005 09:29 PM (Edited 1 times)

theTrinity

theTrinity

David
Status: Offline!

Ohh, thats nice. Thanks, BT.

Hope to see Neverside's version soon. :)

johnzer

johnzer

Neverside Newbie
Status: Offline!

Damn! Dreamhost doesn't support wildcard DNS :(

No other way around this then? (Without actually creating the subdomains that is)

mcdude

mcdude

Blah
Status: Offline!
Originally posted by johnzer:

Damn! Dreamhost doesn't support wildcard DNS :(

No other way around this then? (Without actually creating the subdomains that is)

You could ask their tech support to enable it for you?

johnzer

johnzer

Neverside Newbie
Status: Offline!

I tried, :(

Quote:

We do not support Wildcard DNS, unfortunately. Our apologies.

If there is anything more we can help you with, please let us know and we
will be more than happy to accommodate.

Thanks!
Jeff T.

Last edited by johnzer, September 13th, 2005 06:54 PM (Edited 1 times)

Page 1 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0187 seconds.