Interpolated Strings

The mod_vhost_alias module supports various interpolated strings, each beginning with a % symbol and followed by a number. As you have seen, %0 references the entire Web address. %1 references only the first segment, %2 references the second, %-1 references the last part, and %2+ references from the second part on. For example, if you want to use only the second part of a Web address for the directory name, you would use the following directives:

VirtualDocumentRoot /var/www/hosts/%2/html VirtualScriptAlias /var/www/hosts/%2/cgi-bin

In this case, a request made for would use only the second part of the Web address. This would be "mygolf" in, and would evaluate to


If you used %2+ instead, as in /var/www/hosts/%2+/html, the request for www.mygolf .com/html/mypage would evaluate to


The same method works for IP addresses, where %1 references the first IP address segment, %2 references the second, and so on.

Was this article helpful?

0 0

Post a comment