Vhosting Redirection

 

The Idea

A small trick you can use with Apache and PHP is that of using the name contained within a URL to relocate or display a page relative to the URL. For example, the url http://example.x0f.org. You can then redirectYou will need Apache compiled and configured to use mod_vhost_alias. Firstly, you'll need to setup your usual configuration for your site (ie, x0f.org/www.x0f.org) and then set up a redirection vhost where you will place your php script that will handle redirections.

 ServerAdmin admin@localhost
DocumentRoot /usr/home/web/x.x0f.org
ServerName x.x0f.org
ServerAlias *.x0f.org
After restarting Apache, check your vhost is now working alright, don't also forget that you will need to add a DNS entry to your DNS servers to wildcard the remaining DNS. The PHP part of the script is pretty simple, you can display something based upon the hostname (such as 'Hello Bob' for http://bob.x0f.org)

October 19th, 2005

Comments

No users have commented on this post yet.