There's already a free version for this: https://wordpress.org/plugins/multiple-domain-mapping-on-single-site/

This one might be a bit more polished, but it basically does the same thing.

Just putting this out there :)