Posts Tagged ‘user dependent url’

For testing purpose add host entry in windows.

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

127.0.0.1 myprofile.com
127.0.0.1 john.myprofile.com
127.0.0.1 lisa.myprofile.com
127.0.0.1 mathew.myprofile.com

 

Add below code in apache httpd.conf file.

DocumentRoot "d:/wamp/www/"
<VirtualHost 127.0.0.1>
ServerName www.myprofile.com
DocumentRoot d:/wamp/www/inhouse-demo/myprofile/
</VirtualHost>

 

Once all done restart wamp & clear browser cache.

Now when you open http://myprofile.com it will redirect to your project home page.

Same way with http://john.myprofile.com and http://mathew.myprofile.com.

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.