Redirecting based on the URL passed

I needed to consolidate a couple of servers down to a single machine, but the system’s users were used to entering a certain URL. DNS was the easy part, just create a CNAME record to point to the host. But how to direct users who enter the CNAME (call it cname.domain.com for example) to one directory while still directing the users from the original host (using hostname.domain.com) to the content they are used to seeing? There are probably more elegant ways to do this, but I simply created an index.php file to look at the URL passed and redirect them to the proper content. See the file below:

> index.php

Leave a Response