As a webmaster, upon creating your first site, you may want to install a program like WAMP or EasyPhp. You then put your site in the /www/ directory and it is then accessible via the URL: http://localhost/
But will happen if you start to develop several sites simultaneously?
You end up with a multitude of sub folders, and URLs to extension, for example:
Which will act as the site root url in the development phase.
The problem is that absolute and relative URLs do not work when you host your site (live) and sometimes you may be confronted to legnthy urls to access the site, etc. ...) then this tutorial will be helpful .
The objective of the tutorial
We will make use of short addresses such as: http://myproject.dev/
- This tutorial was written for people working under Windows environment, and using Wamp server. But you will probably have no difficulty to implement this method with other software.
- Assuming you have installed WAMP under C:\wamp\.
- Assuming you have placed your current project under C:\wamp\www\MyProject\.
- You need a text editor, such as Notepad.
Set the host for windows
- Open the file:
- At line 20 you should have something like this:
And save the file.
If you can not edit the file, verify that it is not read-only.
Under Vista, you may encounter more problems with the UAC. Make a copy of the file on your desktop, set the write permissions, make the change, then put the file in read-only, and overwrite the original file.
Launch Wamp click on the icon in the taskbar, click on "Apache" and you should see entries of the dropdown the httpd.conf file. Open this file and make the necessary changes.
- You can find this file in
At the end of the file, add this:
## MAIN DOMAIN
## DOMAIN of myproject
It is essential to properly put the two host definitions. If you do that part 2) then the url http://localhost/
will bring up the folder containing your project. This is not desired, because you need to access the directory /www/.
- Save the file.
- Restart your apache server.
Editing the "httpd.conf" file can be tricky when you have not mastered the subject entirely. This file is essential for the proper operation of Apache, a simple error can prevent the server from starting.
To avoid modifying this file, WAMP provides a default alias file ( C:\wamp\alias\ )
In this folder, create a new text file and name it: localhost.conf, then copy the contents:
## DOMAINE principal
Also in the same folder, create a new text file and name it: myprojet.dev.conf, then copy the contents:
# # Myprojet.dev
# # FIELD of MyProject
DocumentRoot C: / wamp / www / MyProject /
Save them and then restart the Apache server.
If an error is made when creating an alias, just delete the concerned file to find the original configuration.
If everything went well:
Thanks to gryzzly for this tip.