PHPBuilder - faking real vhosts



RSS Twitter
Tips Tricks And Hacks

faking real vhosts

by: Nico Gawenda
|
June 4, 2002

put this at the very beginning of your php
this powerful hack implies to have *.yourdomain actually pointing to it.
first check for some vhost. this can be done much better, but this is easier to understand :-)
if (isset($HTTP_HOST) && strpos($HTTP_HOST,'.yourdomain.com')>0 && strpos($HTTP_HOST,'www.yourdomain.com')===false ){
	// extract vhost, again put your regexp here ;)
	$vhost = substr($HTTP_HOST,0,strpos($HTTP_HOST,'.'));
	// redirect whereever you want... you could also look for an id with username=$vhost in a database,
	// and redirect to something like /index.php?show_user=$id
	header('Location: http://www.yourdomain.com/'.$vhost.'/index.php');
	exit;
}

just my 2cents, i hope it helps :)

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Nico Gawenda

Comment:



Comment:

(Maximum characters: 1200). You have characters left.