You can create a virtual host on your local system or your sever. i.e. you can have http://trial/ instead of http://localhost/trial/ where trial is the name of the directory that contains the website.
Here are the steps for creating virtual host on your sever:
1) open the host file and edit it as follows:
the host file is found at C:\WINDOWS\system32\drivers\etc\hosts for windows
open the file and add the following code to the bottom of the file on a new line
192.168.6.181 trial
2) Now open the httpd.conf file under the apache/bin/conf/ directory
and add the following code : # Virtual hosts
Include conf/extra/httpd-vhosts.conf
or if already present then please uncomment the following line
: Include conf/extra/httpd-vhosts.conf
i.e. remove the # from the front of the line
3) Open apache/bin/conf/extra/httpd-vhosts.conf file
if not present create directory extra under
apache/bin/conf/
and create a file httpd-vhosts.conf file
and add this code to the file:
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn’t need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option ‘-S’ to verify your virtual host
# configuration.
<Directory D:/wamp/www/vhosts>
Order Deny,Allow
Allow from all
</Directory>
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.localhost
# DocumentRoot “C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.localhost”
# ServerName dummy-host.localhost
# ServerAlias http://www.dummy-host.localhost
# ErrorLog “logs/dummy-host.localhost-error.log”
# CustomLog “logs/dummy-host.localhost-access.log” common
#</VirtualHost>
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host2.localhost
# DocumentRoot “C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.localhost”
# ServerName dummy-host2.localhost
# ErrorLog “logs/dummy-host2.localhost-error.log”
# CustomLog “logs/dummy-host2.localhost-access.log” common
#</VirtualHost>
<VirtualHost *:80>
DocumentRoot D:/wamp/www
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot D:/wamp/www/vhosts/trial
ServerName trial
</VirtualHost>
if the file is present then please add the following lines at the bottom of the file
<VirtualHost *:80>
DocumentRoot D:/wamp/www
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot D:/wamp/www/vhosts/trial
ServerName trial
</VirtualHost>
4) restart your apache services and just type http://trial/ into the address bar of your browser and it will work
If you face any problem with this please feel free to contact me. I’ll try to resolve your problem as soon as possible.
Thanks,
Sachin (samsami2um@gmail.com)