PHP manage user dependent pages – Apache create virtual host

Posted: September 18, 2012 in PHP
Tags: , ,

For testing purpose add host entry in windows.

Open C:\Windows\System32\drivers\etc\hosts fiel and add below code at bottom of file.


Add below code in apache httpd.conf file.

DocumentRoot "d:/wamp/www/"
DocumentRoot d:/wamp/www/inhouse-demo/myprofile/


Once all done restart wamp & clear browser cache.

Now when you open it will redirect to your project home page.

Same way with and

Now you can add below php code on top of your php file.

$domain = $_SERVER['HTTP_HOST'];
$subdomain = substr($domain, 0, strpos($domain, '.'));

Now use subdomain variable and check in database for user dependent data.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s