Redirect to another web-site using a frame/frameset
Posted by jpluimers on 2014/04/30
Every once in a while, you have a domain but the hosting is at another party that does not allow setting the “Host header” for name based virtual hosting.
So then you want to redirect the page to the hosting party, preferably with keeping the URL in the address bar.
Some how, when searching how to do this (I do it once every couple of years), I always miss the WikiPedia entry at the bottom of this post.
Basically, there are a couple of ways for this:
- frameset
- head meta refresh
- JavaScript window.location.href (which is different from top.location.href)
Only the first one keeps the current URL in the address bar of the browser. The other ones will show the new target url in the address bar.
Notes:
- in HTML5, the noframes part is not allowed any more.
- the meta refresh has no extra quotes around the URL, the quotes are around the full text of “0; url=http://TARGET.URL/PATH”
Examples:
Frameset
<html>
<head>
<title>TITLE OF YOUR SITE AND YOUR REDIRECT</title>
</head>
<frameset rows="*,0">
<frame src="http://TARGET.URL/PATH" name="redirect_main" marginwidth="0" marginheight="0" frameborder="0" noresize="noresize"/>
<noframes>
<body>
<p>
Uw browser ondersteunt geen frames. Klik <a href="http://TARGET.URL/PATH">hier</a> om naar de TITLE OF YOUR SITE AND YOUR REDIRECT site te gaan.
</p>
<p>
Your browser does not support frames. Please click <a href="http://TARGET.URL/PATH">here</a> to continue to the TITLE OF YOUR SITE AND YOUR REDIRECT site.
</p>
</body>
</noframes>
</frameset>
</html>
Head meta redirect
<html>
<head>
<title>TITLE OF YOUR SITE AND YOUR REDIRECT</title>
<meta http-equiv="Refresh" content="0; url=http://TARGET.URL/PATH" />
</head>
</html>
JavaScript
<html>
<head>
<title>TITLE OF YOUR SITE AND YOUR REDIRECT</title>
<script type="text/javascript">
window.location.href="http://TARGET.URL/PATH";
</script>
</head>
</html>
–jeroen
via:






Leave a comment