A rewrite rule is typically used in conjunction with Setup->Domain Mapping to provide the mapping method to be used to route email addresses through streams.
(0) Check that you are in the default stream of the realm with your domains. The upper-left corner always shows your context.
(1) Go to Setup : User Lookups. Add a new User Lookup.
(the name doesn't really matter, I suggest "CompanyName-Rewrite")
(2) From the dropdown, select "Rewrite" as the type.
(3) At the next step, define the rule as:
That means when this rule is used, the domain part of the stream will always be companyname.com no matter what.
(4) Click through and Finish.
(5) Go to Setup : Domain Mappings. Create a new line for each of the alias domains (if it isn't already there) and on the right, set it to use the rewrite rule ("CompanyName-Rewrite").
You can apply this rule to the primary domain as well to keep this screen looking consistent.
That will do it. The Domain Mapping is merely how the spam trap name is chosen; it doesn't affect delivery at all, the messages will be delivered to the original recipient address. This merely means that any emails to the alias domains will be processed through the same spam trap as the same username in the primary domain.