DekGenius.com
[ Team LiB ] Previous Section Next Section

Recipe 5.5 Aliasing Several URLs with a Single Directive

Problem

You want to have more than one URL map to the same directory but don't want multiple Alias directives.

Solution

Use AliasMatch in http.conf to match against a regular expression:

AliasMatch ^/pupp(y|ies) /www/docs/small_dogs

Discussion

The AliasMatch directive allows you to use regular expressions to match arbitrary patterns in URLs and map anything matching the pattern to the desired URL. Think of it as Alias with a little more flexibility.

This example causes URLs starting with /puppy, as well as URLs starting with /puppies, to be mapped to the directory /www/docs/small_dogs.

Apache's regular expression syntax is discussed in much greater detail in Appendix A.

See Also

  • Appendix A

  • Mastering Regular Expressions by Jeffrey Friedl (O'Reilly)

    [ Team LiB ] Previous Section Next Section