Everyone like to host their site in the name they wanted to host, but most of time it is not possible because someone already bought that domain and hosted their sites. You can make your dream to come alive by setting virtual host in your local system, where you can host your site even in the name of google.com. It much easier and very interseting too setup this on your localhost and see the output.
To setup a Virtualhost in local, all you need to do is edit the following two server configuration files (hosts.file, httpd-vhosts.conf) in the following location if your are Windows 7 user.
Find hosts.file in the following location (C:\Windows\System32\drivers\etc\hosts.file), then right click on it and open with administrator privilage.
Now add following line at the end of the file.
Now when we type google.com in the browser address bar by default it points to its localhost. What we had done so far is, we added new domain name to our host file, by default it points to localhost until we espically specify specific directory for that domain name in the httpd-vhosts.conf file.
Here is flow chart what happens when we enter any domain name in our browser address bar.
Now find the httpd-vhosts.conf in the following location (C:\xampp\apache\conf\extra\httpd-vhosts.conf), then right click on it and open with administrator privilage.
Now add the following script at the end of the file.
<VirtualHost *> DocumentRoot "D:\google" ServerName google.com <Directory "D:\google"> Order allow,deny Allow from all </Directory> </VirtualHost>
Note : please restart our local apache server, only after restart chages we made in the httpd-vhosts.conf will take effect.
what we had done now is mapping the domain, that we added in the host file with the directory in our local system. Here I had mapped google.com with the google directory in the D:\ drive. Now when we enter google.com in the browser address bar the files in the D:\ drive google directory will be displayed.
Note: See in the demo page screen instead displaying google home, it displays the local site I had hosted in my D:\ drive.
DocumentRoot (‘D:\google’) — Specifies root folder
ServerName — google.com
Now when type google.com in the browser address bar, first of all server looks for the file in the DocumentRoot (‘D:\google’) folder, then it finds requested file that root folder, then it displays output files in the browser.
Download Premium Only Scripts & 80+ Demo scripts Instantly at just 1.95 USD per month + 10% discount to all Exclusive Scripts
If you want any of my script need to be customized according to your business requirement,
Please feel free to contact me [at] muni[at]smarttutorials.net
Note: But it will be charged based on your customization requirement