Upgrade url_for to search for resources relative to their destination paths as well as their source paths. This would fix #818.