Here we are redirecting to example.netlify.app from current domain (where this file is hosted).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://example.netlify.app" />
<noscript>
<meta http-equiv="refresh" content=";url=https://example.netlify.app">
</noscript>
<title>Example</title>
</head>
<body>
<script type="text/javascript">
var url = 'https://example.netlify.app' + window.location.pathname;
var referLink = document.createElement("a");
referLink.href = url;
document.body.appendChild(referLink);
referLink.click();
</script>
</body>
</html>