Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm working on an application for my clients that allows them to set up small landing pages for their campaigns. I have a set of templates and views for adding text, photos etc to the templates. Everything works pretty well straight out of the box, with authentication, admin views etc. I'm using the Laravel framework.

Each client and campaign has an url friendly title to use in custom front end URL, i.e. "campaignsite.com/c/client/campaign". These URL titles are unique. In addition to this, I want to allow my clients to point custom subdomains (or any domain for that matter) to their campaign. For example would pointing the domain "campaign.client.com" fetch the correct front end for that campaign. I've solved this very easily in Laravel, just by adding an input field for custom URL, and looking that up in the front end.

However, I have problems with setting up virtual hosts in Apache correctly. I have an VPS with multiple sites, all which have the following configuration:

<VirtualHost *:80>
  DocumentRoot /data1/www/kampanjeweb/public
  ServerName kampanjeweb.redhost.no

  LogLevel warn
  ErrorLog /logs/www/kampanjeweb_error.log
  CustomLog /logs/www/kampanjeweb_access.log common

  <Directory />
    AllowOverride All
    Options FollowSymLinks MultiViews
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

With this vhost snippet I need to define each ServerAlias server, but I would love to be able to let the clients update their custom URL settings without having me to do any customizing.

Have any of you done this before? What I basically want, is that any domain or request that doesn't match any of the virtual hosts files in Apache, should go to this virtual host.

share|improve this question
add comment

1 Answer

Rename this virtual-host to 000-<old name> Making sure it sorts first lexicographically. When requests come to the server that doesn't match any of your vhosts, it will default to the first one.

share|improve this answer
add comment

Your Answer

 
discard

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.