i am not sure that PHP can actually do this. Its more a server problem.
I use apache and you can set up virtual hosts like this in httpd.conf:
<VirtualHost *>
DocumentRoot /blah/
ServerName blah.com
</VirtualHost>
<VirtualHost *>
DocumentRoot /blah2/
ServerName blah2.com
</VirtualHost>
I'm sure all servers have a similar system.