Transcending the boundries of frame redirects

Many hosters offer cheap domains without a webhosting package. Some of those hosters e.g. Strato only give you the option to use a frame redirect with this domains. But sometimes you can’t see that restriction when you order the domain.

Some might be happy, as they have a free hosting package with a very long URL, so they can use the frame redirect to only present a short URL to the visitors. But there’a a catch with frame redirects.

The Bookmarking Problem

Navigating through your site works as expected. The visitor can click each link which will update the main frame. Also navigation with the “Back” and “Forward” button works perfectly. But as soon as the visitor finds a nice page he want to add to his favorites, the trouble begins. Not only the title of the bookmark is the domain name, but also the bookmarks target. So when the visitor opens the bookmark he will only get the homepage and he has to navigate to the desired page again.

The Searchengine Problem

Most of the search engines (including Google) have trouble with framebased sites. Most of them can only the the frameset construction which doesn’t contain any content and they can’t access the content of the frames. So in worst case that means that your page with tousands of pages will only have ONE entry in the search engine and this page is the homepage of the redirected domain. A possible solution is to create a sitemap. You should than tell the search engines manually about this sitemap as some of the search engines can’t even find the sitemap on your site. In the sitemap you can use the URL of your webspace or the URL of the domain and append them with the pagename.

The Solution

Both problems are showing that frame redirects are a relict of the old days and you should avoid to use them. But what to do if your hoster doesn’t support HTTP redirects or only offers them for an additional charge? It’s quite easy, you only have to use a simple trick. You first have to create a new folder on
your site. That you point the domain to this folder. In the folder you create a index.php (or an equivalent index page of another scripting lanuage) with the following content:

<script type="text/javascript">
	top.location.href = "";

This simple JavaScript Snippet changes the URL of the top frame to a new value. So when a visitor access your page that only supports frame redirects, this piece of code redirects the highest frameset to the new URL. Your just have to replace the “” with your domain name (and don’t forget the “http://”). For all visitors with deactivated JavaScript functionality you should use a normal link within a NOSCRIPT tag:

	If you should not be redirected, please click the follwoing link:
	<a href="" target="top"></a>

The link gets a “target” attribute with the value “top”. So clicking on the link will also update the highest frameset. To enable visitors to access a specific page on your site, you can append the request to the domain. Doing so will redirect the visitor to the correct page on your other domain. Adding the whole code together it should look like this (or similar for other scripting languages):

<script type="text/javascript">
	top.location.href = ""<?php echo $_SERVER['REQUEST_URI']; ?>
	If you should not be redirected, please click the follwoing link:
	<?php echo '<a href="'.$_SERVER['REQUEST_URI'].'" target="top">'.$_SERVER['REQUEST_URI'].'</a>'; ?>

You just habe to place this into the BODY tag of the index page. But you should present the visitors without JavaScript a nice page and not only a page with a link on white background.

As I also got a domain which I cannot move to my current hosting package you can see a little example right here. You should turn off JavaScript to see the page and the source code. After reactivating JavaScript and reloading the page, you should be redirected to the blog.


With this little trick you can by-pass frame redirects but you will than present your visitors a diffrent URL than they have entered. But you should favor this case over breaking the bookmaring feature and the search engine problem. You can still use the short domain in mails and then redirect the visitors. If you want to fully use the domain with your website you have to transfer them to your webhosting package or find a diffrent domain provider that offers HTTP redirects, even if you have to pay an additional charge.

Posted by

Bernhard is a full time web developer who likes to write WordPress plugins in his free time and is an active member of the WP Meetups in Berlin and Potsdam.

6 comments » Write a comment

    • Wenn du möchtest, dass die Parameter nicht übergeben werden, dann könntest du sie einfach vorher entfernen, bevor du den Redirect im JavaScript einfügt. Z.B: wie folgt:

      &lt;script type=&quot;text/javascript&quot;&gt;
         top.location.href = &quot;;&lt;?php echo str_replace($_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI']); ?&gt;

      Das würde alle Parameter entfernen und somit immer auf die Seite weiterleiten, die du in der kurzen URL angegeben hast.

      Ich habe mittlerweile die Domain auf ein aktuelles Paket umgestellt. Dort habe ich die Möglichkeit eine DNS Weiterleitung zu machen. Mein alter Vetrag hatte 0,19€ pro Monat für die Domain gekostet und der neue kostet nun 0,49€. Aber da ich dadurch einen “neuen” Vertrag bekommen habe, ist das erste Jahr wieder kostenlos gewesen.

      Also versuche es mal mit meinem Trick oder überlege dir den Vertrag auf einen aktuellen mit HTTP-Weiterleitung oder DNS-Eintrag umzustellen.

      • Danke für die Informationen. Guter Tip.
        Aber im Grunde will ich ja die Parameter übergeben, nur so, dass sich der Domain-Name nicht ändert ^^

        • Tja, das geht leider nicht. Damit sich die Domain beim Nutzer nicht ändert musste du es bei einer Frame-Weiterleitung belassen oder eben eine echte HTTP-Weiterleitung nutzen. Ich würde dir also vorschlagen dein Domain-Paket auf eine höheres upzugraden damit du die HTTP-Witerleitung nutzen kannst.

  1. Der Tipp hilft leider nur für Besucher, nicht für Suchmaschinen, die kein Javascript interpretieren. Diese ‘kostenlosen’ Strato-Domains produzieren leider duplicate content.


    • Das ist leider war. Aber es hilft zumindest für Benutzer, die die Website besuchen möchten. Eine Domain mit Frames ist immer schlecht für Suchmaschinen indizierbar. Aber dass es Domains kostenlos bei Strato geben soll, ist mir neu.

Leave a Reply

Your email address will not be published. Required fields are marked *