The Alias directive is used to map between URLs and filesystem paths.
This allows content which is not directly under the DocumentRoot to serve as part of the web document tree.
- How to make an Alias in Linux:
Edit your Apache config file and add an Alias Directive. For example, let's use the default file.
sudo -e /etc/apache2/sites-enabled/000-default
-e => any editor you use.
Make your alias by adding a section within the VirtualHost directive:
Alias /customers/ "/CUSTOMERS_PATH/"
Allow from all
Save and restart:
sudo /etc/init.d/apache2 restart
- How to make an Alias in windows:
- 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).
Type the name of the alias; this will be what is added onto the http://domain_name/ address
Enter the location of the folder that will house the pages for this site. Keeping with our example, type D:\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 on one line:
Alias /CUSTOMERS/ “D:\CUSTOMER_DATA” <Directory “D:\CUSTOMER_DATA/”> Options Indexes FollowSymLinux MultiViews AllowOverride all order allow, deny Allow from all</Directory>
The file should look like this:
Alias /CUSTOMERS "D:/CUSTOMER_DATA"
Options Indexes FollowSymLinks ExecCGI
Order Deny, Allow
Allow from all
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 D:\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.