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)



Apache Cookbook
Apache Cookbook: Solutions and Examples for Apache Administrators
ISBN: 0596529945
EAN: 2147483647
Year: 2006
Pages: 215

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net