The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,570 other followers

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:

  1. frameset
  2. head meta refresh
  3. 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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: