0

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

subdomain.heroku.com 

to

www.whatever.com.

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

frequent
  • 167
  • 8

1 Answers1

2

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.

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • Ah. So, I could do something similar on Apache? – frequent Jun 27 '12 at 06: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
  • 1
    @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