I found this blog about how to create dynamic subdomain using htaccess. I will try this at home later. Actually you just need to type this on your htaccess with modrewrite
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourwebsite.com
RewriteCond %{HTTP_HOST} ([^.]+)\.yourwebsite.com
RewriteRule ^(.*)$ /path_to_your_site/httpdocs/work_out.php?url=%1
This will render abcd.yourwebsite.com into yourwebsite.com/wor_out.php?url=abc
Isnt it simple enough ?
I will try this at home and learn more about mod_rewrite.
In case you want to know more about mod_rewrite, read this cheatsheet from Ilovejackdaniels.
berarti, DNS server harus diatur untuk DNS Wildcard Record untuk domain tersebut.
tanpa itu, dynamic subdomain gak akan bisa resolve.
CMIIW
By: rusd on September 28, 2007
at 10:24 am
yap, that’s right, we need wildcard dns for that. in linux must be type in *.yourdomain.com so that it will refer to yourdomain.com
but i dont know how to do that in windows since wildcard is not allowed. I tried to google around, and found dnscmd by microsoft, but i have not tried it yet
By: Adwin on September 29, 2007
at 2:20 am
but for testing purpose you can just type abc.yourdomain.com
def.yourdomain.com
in windows\system32\driver\etc\hosts
By: Adwin on September 29, 2007
at 2:22 am
hmm, thanks for reply.
where you from? Indonesian?
Adwin, Indonesian name look-like.
By: rusd on September 29, 2007
at 12:23 pm
yes i’am
[i use english so that others can read]
nice to know you too mr rusd
By: Adwin on October 1, 2007
at 3:16 am
More information about subdomains setup :
http://groups.google.com/group/cake-php/browse_thread/thread/5a576a5fbc68e6a1
By: Adwin on October 1, 2007
at 3:46 am
You really know your programming – cool!
I’ve been to Indonesia – the Riau Islands. Hope to get back there someday.
Keep up the good work with your blog. Not to over promote, but you should check out my website. Maybe you can find grants for a graduate degree in computer science.
Good luck!
BA
http://www.scholarshisp.com
By: BA on February 12, 2008
at 9:15 pm
It works, but not in Drupal site (www.drupal.org)
There are not loaded styles and java scripts
:(
Any glue?
By: Jiri on February 25, 2008
at 12:04 pm
i would like to create subdomain by htaccess but
the code as i have used is not working so help to find the solution
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.vision.com
RewriteCond %{HTTP_HOST} ([^.]+)\.vision.com
RewriteRule ^(.*)$ /public_html/index.php?url=%1
By: animesh on June 9, 2008
at 8:01 am