Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been looking at the Heroku custom domain feature, which enables to change a url from 


Is something like this possible with mod_rewrite or how is this done? It can't be a simple re-direct, can it?

share|improve this question
up vote 2 down vote accepted

No rewriting is necessary. They achieve this by adding your domain to the list of HTTP Host headers that will be mapped to the handler that also handles your subdomain under their own domain. In Apache configuration terms, the equivalent configuration is ServerAlias.

share|improve this answer
Ah. So, I could do something similar on Apache? – frequent Jun 27 '12 at 6:54
@frequent Sure - though to have it be client-initiated, you'd need to have the clients have a mechanism to update that config, then have the Apache service gracefully restart to pick up the configuration changes. – Shane Madden Jun 27 '12 at 16:24
Yes, I was thinking something like this. Client can "pick" his URL to run on my system. If you have any pointer where to get me started, you'd make my evening, too (made my day already...). Thanks! – frequent Jun 27 '12 at 16:44
@frequent Well, something like that can get very complicated pretty quickly, and there are a lot of different ways to approach it. The smooth, scalable way would probably involve some kind of configuration management system, like Puppet or Chef.. but the simplest implementation would probably be to have the user's desired configuration from a web form stored in a database, then have a shell script running as a cron job once every 15 minutes that looks at that database (or a web service) for the config, dynamically builds the Apache configs, then gracefully restarts Apache. – Shane Madden Jun 27 '12 at 17:20
Ok. Sounds good. I will give this a try sooner or later (more later... ) Thanks again for helping out! If I get to it and get stuck, I'll post here, maybe you can chip in again. – frequent Jun 27 '12 at 17:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.