I tried using <rewrite>
in web.config and received HTTP Error 500.19 error code 0x8007000d.
Went to IIS Manager, found the "URL Rewrite" icon (which means that the module is already installed and I don't have to install it again), but clicking on it gave a generic "There was an error while performing this operation" error.
It didn't matter which website (or the server itself) I selected, clicking on the corresponding "URL Rewrite" icon still gave the same error message.
At some point the error message started showing an additional detail: "The configuration section 'system.webServer/rewrite/globalRules' cannot be read because it is missing a section declaration", I cannot recall changing anything, so I don't know what caused it to appear, so this is just an FYI.
I searched and found lots of other posts that contributed to the final solution, below are the steps that solved it for me: