Thanks for providing the patch Paul,
add_to_log is just populating log table and has nothing to do with redirect.
I tried replicating this issue on master and it seems to be working fine, (moodle installed in sub-dir).
Can you please confirm if $CFG->wwwroot is set properly.
Also, it will be helpful if you can provide some more details about your installation, as I was unable to replicate this issue with testing instructions provided in this ticket.
FYI: links in add_to_log are relative and get reconstructed as per module. Please check other areas like book/view.php, url/view.php etc.