How to make 3 domain name in a single IP or machine.
Like:
1. http://moushami.com/
2. http://need11.com/
3. http://bharatbaba.com/
Before to show the code I want to show you the output in screen shot, so you can understand what exactly I want to say about this:
Screenshot1:
Screenshot2:
Screenshot3:
Screenshot4:
Screenshot5:
Well, so now you can understand about this:
Open this file in notepad: C:/Windows/System32/drivers/etc/hosts
Before to change any thing please keep a backup of hosts file.
Now add this line at very bottom of this file:
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
#127.0.0.1 zend
#127.0.0.1 zend2
#127.0.0.1 zf2
#127.0.0.1 localhost
127.0.0.1 localhost
54.251.72.154 mavsocial.com
#127.0.0.1 hotdoodle_engine.localhost localhost
127.0.0.1 vhost1
127.0.0.1 vhost2
Now open this file in your notepad and please keep backup before to any change:
C:wampbinapacheApache2.4.4confhttpd.conf
Now come to very bottom of this file and add below lines:
IncludeOptional "c:/wamp/vhosts/*"
Include "c:/wamp/alias/*"
# Listen for virtual host requests on all IP addresses jay start
NameVirtualHost *:80
<VirtualHost *:80>
#DocumentRoot /www/example1
DocumentRoot C:/wamp/www/vhost1
ServerName vhost1
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/wamp/www/vhost2
ServerName vhost2
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/wamp/www
ServerName localhost
# Other directives here
</VirtualHost>
#jay close
Now add 2 folder inside your localhost:
C:/wamp/www/vhost/1index1.php
C:/wamp/www/vhost2/index2.php
Now restart your apache server or all services
then in browser write this line:
http://vhost2/index2.php
http://vhost1/index1.php
http://localhost/
Your work is done.
Reference:
1. http://httpd.apache.org/docs/2.4/vhosts/ip-based.html
2. http://httpd.apache.org/docs/2.2/vhosts/examples.html
Share on Facebook
Page views:1260