Setting up an Alias in Apache

Aliases are easy to set up in Apache and they're very useful. Here is an alias that I set up inside my application virtual host. They can be set up in localhost as well, and my explanations are based on localhost.

alias /phpMyAdmin "D:/programming/web/applications/www/phpMyAdmin-3.5.0"
    <Directory "D:/programming/web/applications/www/phpMyAdmin-3.5.0">
        Require all granted
    </Directory>

Imagine that this were set up at the root level on localhost. Instead of navigating to localhost/phpMyAdmin-3.5.0 I can link directly to it via the alias localhost/phpMyAdmin. The benefits of this are that the directory structure and the URI can be different. In this example the directory structure clearly labels the version of the phpMyAdmin I am working with, whereas I don't need to know this for the URI,

When it comes time to upgrade phpMyAdmin I can download the latest release and put it in its own directory and then update the alias. Just remember that any changes that you make to the Apache configuration file will require Apache to be restarted. I can then navigate to the latest version with the same URI that I've always used.

Some points

  • The same technique can be used when you upgrade a web application and you need to provide for a roll back mechanism.
  • The directory that the alias points to can reside outside your web root folder
Tags: 

Comments

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.