WAMP Tip: Alias Directories

It’s been longer than usual since I posted, primarily because course loads have ramped up a bit since Christmas break ended. I finally have time to post this short tip which has been helpful to me.

I use WAMP Server together with NetBeans (which supports PHP quite nicely as of version 6.5) to develop PHP applications on my local machine. This works well because I can do debugging (thanks to xdebug) and can readily view and edit files. I usually don’t like to place projects in the c:\wamp\www  folder, preferring instead to place them in more logical places in my personal directory.

The easiest way to facilitate this is to create Apache aliases to these different locations (for example, my IRPA work goes under http://localhost/irpa). WAMP Server provides an interface for creating new aliases by clicking on the tray icon and selecting Apache -> Alias directories -> Add an alias. A new command prompt window opens where you can enter the alias information.

Creating an alias like this, you’ll probably notice that in order for the URL to work, you have to have a trailing slash at the end (e.g. http://localhost/irpa/ will work while http://localhost/irpa won’t). This can be a bit of a pain, but there is fortunately a quick fix. Click on the WAMP Server tray icon again and select Apache -> Alias directories -> [alias url] -> Edit alias. This will open the alias file in Notepad. Remove the trailing slash from the relative URL.

For Example

Alias /irpa/ "c:/path/to/irpa/"

Would become

Alias /irpa "c:/path/to/irpa/"

Save the file and close Notepad. WAMP Server should restart automatically (if not, you can restart it manually from the tray icon). Once it has restarted, you’re alias should now work with or without the trailing slash. Why WAMP Server doesn’t do this automatically, I’m not sure, but at least there’s a simple fix.