Once the first host/domain specification has been extracted from the address, PMDF consults the rewrite rules to find out what to do with it. The host/domain specification is compared with the pattern part of each rule (i.e., the left-hand side of each rule). The comparison is case insensitive. Case insensitivity is mandated by RFC 822, UUCP addresses notwithstanding. PMDF is insensitive to case but preserves it whenever possible.
If the host/domain specification does not match any pattern, in which case it is said to "not match any rule", the first part of the host/domain specification --- the part before the first period, usually the host name --- is removed and replaced with an asterisk and another attempt is made to locate the resulting host/domain specification, but only in the configuration file rewrite rules (the domain database is not consulted). If this fails the first part is removed and the process is repeated. If this also fails the next part is removed (usually a subdomain) and the rewriter tries again, first with asterisks and then without. All probes that contain asterisks are only done in the configuration file rewrite rules table; the domain database is not checked. This process proceeds until either a match is found or the entire host/domain specification is exhausted. The effect of this procedure is to try to match the most specific domain first, working outward to less specific and more general domains.
A somewhat more algorithmic view of this matching procedure is given below.
For example, suppose the address email@example.com is to be rewritten. This causes the rewriter to look for the following patterns in the given order:
|sc.cs.example.com||configuration file and then domain database|
|*.cs.example.com||configuration file rules only|
|.cs.example.com||configuration file and then domain database|
|*.*.example.com||configuration file rules only|
|.example.com||configuration file and then domain database|
|*.*.*.com||configuration file rules only|
|.com||configuration file and then domain database|
|*.*.*.*||configuration file rules only|
|.||match all rule described in Section 184.108.40.206|
Always remember that patterns involving asterisks are only searched for in the configuration file's set of rewrite rules; no searching is done for these patterns in the domain database.