May
31st

Wildcard DNS and Dynamic Subdomains

Happy New Year! Marketing Technology finds and reports on the latest technology that will enable your business to effectively market to your audience, for acquisition or retention strategies. Subscribe now the Marketing Technology Blog RSS feed or to the Marketing Technology Email to have new content sent directly to your inbox. You'll also find my other business blog helpful, Social Media Domination.

In all my spare time (ha!), I’ve been working to wrap the Wild Birds Unlimited Map application with an enterprise application that will allow folks to design their own store locator. Developing my own Software as a Service solution has been a goal of mine for quite a few years, and this is a great opportunity.

There are two key features off the shelf that I wanted to put into the application that are turning out to be a huge challenge so I wanted to discuss them in the event you’re ever looking to do the same. Both features are commonplace throughout applications, but I’ve come to find out that even though they’re commonplace, many hosting providers don’t actually support them!

My goal is to build a self-service application where the client can configure their own subdomain (http://subdomain.myapplicationdomain.com), or even apply their own subdomain (http://subdomain.yourdomain.com). In order for it to be self-service, it requires the ability to program the solution - but it accesses some domain name server configuration files that are off-limits with the majority of hosting accounts! The issue is support for Wildcard DNS, that is, to be able to point any subdomain to the domain of the server. In other words, test.domain.com or www.domain.com or any.domain.com all point to the same place. No matter what you write - it will work.

Outside of applications, this is actually a pretty nice feature to have enabled - even on your blog. It would allow anyone to write anything.yourdomain.com and bring them to yourdomain.com. You’d be surprised at how many bad links there are that point to your blog or web site. That could be missed traffic if the person doesn’t recognize that it’s an error with the link.

The process works by rewriting the subdomain to a querystring before the page is actually rendered by the webserver… so subdomain.domain.com actually gets interpreted by Apache servers as domain.com?what=subdomain through use of an htaccess file:

# Extract the subdomain part of domain.com
RewriteCond %{HTTP_HOST} ^([^\.]+)\.yourdomain\.com$ [NC]
 
# Check that the subdomain part is not www and ftp and mail
RewriteCond %1 !^(www|ftp|mail)$ [NC]
 
# Redirect all requests to a php script passing as argument the subdomain
RewriteRule ^.*$ http://www.yourdomain.com/%1 [R,L]

There’s some additional information on the files you need to edit at V-nessa.net. Note that the files may not be located where specified depending on your hosting provider. My hosting provider actually is very supportive of folks meddling, but they warn that doing so may void customer support. As well as ‘hack at your own risk’, they aren’t going to reach out to help you, either.

I’m going to work on developing out the rest of the application rather than getting hung up on the subdomain development. I’m actually going to give CakePHP a shot to use as a framework for it!

Last note, I’m a bit of a hack on this stuff. I’m blessed with development teams at my work to figure this stuff out. On my own, I’m a little dangerous. Any feedback and help is appreciated!

You might also find these posts interesting:

RSS feed | Trackback URI

2 Comments »

Comment by Alex Conner
2008-05-31 20:22:37

Very cool. I actually used my registrar’s name server with wildcard DNS when I was with SliceHost, and had Apache configured to serve unconfigured subdomains from the regular domains files.

I was really intrigued to look at the CakePHP framework, but your link is dead :)

CakePHP can be found at http://cakephp.ORG

Comment by Douglas Karr
2008-06-01 00:12:29

I was thinking about going the registry route as well, Alex. That’s a great idea - probably the best way to handle this.

Sorry about the dead link - it’s fixed now.

 
 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

My Comment Policy: I moderate comments. Please be patient:

  • Spam will happily be destroyed.
  • Use your real name, not some keywords. Otherwise it will be destroyed.
  • Mean comments aren't necessary. If I don't post them I will reply personally to let you know why.
  • Lewd comments will be edited, I don't want my readers leaving because of offensive content.
Great debate, criticism and colorful commentary is always appreciated and approved!