While Matrix can (and does) support lots and lots of sites in a single install, it can be better for performance to only configure a single URL for each site in Matrix and use Apache's mod_rewrite rules to handle the rest.
For example, you may have domain.com and www.domain.com. Currently, you would configure both URLs on the Site asset in Matrix, but this results in at least two URLs for every asset. By using mod_rewrite, we can halve the number of database records in at least two tables (sq_ast_lookup and sq_ast_lookup_value for those of you playing along at home).
So, in the above example, let's rewrite all domain.com URLs to their equivalent www.domain.com URL:
Example code:
ServerName www.domain.com ServerAlias domain.com ServerAdmin webmaster@domain.com # Rewrite all domain.com to www.domain.com # The RewriteCond says "Anything that doesn't match www.domain.com" RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC] # The RewriteRule says "Rewrite to www.domain.com with the original path in place" RewriteRule ^/(.*)$ http://www.domain.com/$1 [L,R] # Insert Matrix aliases after the rewrite rules Alias "/__fudge" /path/to/matrix/fudge Alias "/__data" /path/to/matrix/data/public Alias "/__lib" /path/to/matrix/core/lib Alias "/" /path/to/matrix/core/web/index.php/
Notice that we do have [b]domain.com[/b] configured as a ServerAlias in this VirtualHost block. This is because we want Apache to route requests for domain.com to this block so that our rewrite code is processed.
You can do the same for short names to full names. For example, you could have [b]intranet[/b] and [b]intranet.domain.com[/b]. In this case, we'll use the FQDN (intranet.domain.com) in Matrix, because the cookie security prefers it.