Making mod_write and mod_userdir work together

After fighting with Apache for a while I’ve finally managed to get a redirect from a users public_html to a new domain.

The main problem is how mod_rewrite and mod_userdir interact, but the magic syntax to put in the .htaccess inside the user’s public_html is this:

RewriteEngine On
RewriteBase /~user
RewriteRule ^(.*)$$1