Autoredirect if referer origins from same domain

This fixes https://github.com/owncloud/mail/issues/179

@jancborchardt