This configuration can be done in the web.config, and thus can be stored in source control. Here’s what you need to add to your web.config.

        <rule name="Redirect to non-www" stopProcessing="true">
            <match url="(.*)" negate="false"></match>
            <action type="Redirect" url="{R:1}"></action>
                <add input="{HTTP_HOST}" pattern="^domain\.com$" negate="true"></add>

Note: Make sure that for redirecting a site like to, you’ll need to make sure that you’ve configured both of those domains to point to your website.