Ubuntu – Trick Ubuntu into resolving a domain name locally

dns

I have an Ubuntu box that I use for all sorts of things. One thing I really want to do is redirect a sub domain to a local script.

For example thisbit.example.com should actually show the content from localhost/~USER/FAKE.thisbit.example.com/ which is a folder that Apache is running for me which contains a very simple PHP script which implements an offline version of a server script that I am testing against.

But example.com should continue to behave normally as should notthisbit.example.com etc.

Ideally I need to be able to switch from testing to live with minimal fuss when the time comes.

Best Answer

Add your domain name and IP address to /etc/hosts file. For example

127.0.0.1 thisbit.example.com

Edit:

Add configure apache to proxy to your fake path

ProxyPass / http://localhost/~USER/FAKE.thisbit.example.com/

ProxyPassReverse / http://localhost/~USER/FAKE.thisbit.example.com/

Related Question