If I understand this correctly….
First the Rotation
Make a Custom Orientation with the Object that you want the Rotation matched to selected:


Then select the Object that you want to match and:


Now, if you only want the Origin matched, use this Option:

For the Location (whether only the Origin or the whole Object), presss CTRL+S:

And you get:

Hope this helps, please ak if something is still unclear.