Ok if you have working code and it just needs to be integrated into or replaces the WP Rewrite Loop Start code then you would do these steps:
1. Add your customized WP Rewrite Loop Start code in this BPS Root Custom Code text box: CUSTOM CODE WP REWRITE LOOP START: Add www to non-www/non-www to www code here
2. Click the Save Root Custom Code button.
3. Go to the Security Modes page, click the Create secure.htaccess File AutoMagic button and activate Root folder BulletProof Mode.