PHP manage user dependent pages – Apache create virtual host

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.