If you've installed a Windows Apache MySQL PHP (WAMP) server, you most likely realized very quickly how much power is at your fingertips. Unlike its Internet Information Services (IIS) counterpart, Apache is not just about power, though, it's also about flexibility. With a WAMP server, one thing you can do easily is set up aliases on your server.
What's an alias?
Let's say you're using the document root for the main site, and you want to direct the server directories outside of the document root. For example, you want to map the following:
- customers → C:\CUSTOMER_DATA
- repairs → C:\REPAIRS
- engineers → C:\ENGINEERS
The way you go about it is not exactly intuitive when you're using a WAMP server. By default, the WAMP server interface allows you to quickly set up those aliases; however, the end result doesn't work.
I will explain how to use the WAMP server interface to create the basic alias and then how to correct the setup created by WAMP. You'll have to manually edit a configuration file, but I'll give you the foundation of the configuration to use. First, let's interact with the interface. I assume you have already installed WAMP.
Using the interface
Left-click the system tray icon and then go to Apache | Alias Directories | Add An Alias (Figure A). A command prompt window will open prompting you to create the alias for the URL (Figure B).
Creating an alias on a WAMP server is easy.
Creating an alias with the WAMP server GUI.
Enter the location of the folder that will house the pages for this site. Keeping with our example, type C:\CUSTOMER_DATA\ and then hit Enter.
The alias is now set up — according to WAMP — but it doesn't work. The GUI tool isn't good at creating the alias configuration. Never fear, it's a breeze to resolve.
Editing the file
When you create the alias using the WAMP interface, it will create the necessary file in the correct location. The problem is the file's content. What WAMP creates looks like this, which will be all in one line:
Alias /CUSTOMERS/ “C:\CUSTOMER_DATA” <Directory “C:\CUSTOMER_DATA/”> Options Indexes FollowSymLinux MultiViews AllowOverride all order allow, deny Allow from all</Directory>
The file should look like this:
Alias /CUSTOMERS "C:/CUSTOMER_DATA" <Directory "C:/CUSTOMER_DATA"> Options Indexes FollowSymLinks ExecCGI AllowOverride all Order Deny, Allow Allow from 127.0.0.1 Allow from ::1 Allow from localhost </Directory>
To edit that file, follow these steps:
1. Left-click the WAMP icon in the system tray.
2. Go to Apache | Alias Directories | ALIAS_NAME | Edit Alias (ALIAS_NAME is the name of the alias you just created).
3. In the newly opened Notepad window, edit the configuration file to reflect the above contents and save it.
4. Edit the configuration file to best fit your needs (according to the Apache specifications).
After you save the file, restart the WAMP server, and you should be able to point your browser to http://localhost/CUSTOMERS. (Of course, you'll need content within the C:\CUSTOMER_DATA directory.) If you get an error, check to make sure the alias directory's permissions allow the server to read the contents; this will be dictated by a number of issues, such as whether the server resides on a Windows domain.
If you're looking to create server aliases, you can't beat the simplicity of doing so on a WAMP server. Hopefully, the developers will solve the issue with the GUI tools creating correctly formatted configuration files.
Next time around, we'll focus on creating Virtual Hosts on your WAMP server.
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.