Search code examples
htmlrefreshmeta-tagsforwarding

Are there situations in which the following forwarding doesn't work?


I need to implement a forwarding. I did it the following way:

<html>
<head>
<meta http-equiv="refresh" content="0; URL=http://www.xyz.com">
</head>
<body>
</body>
</html>

Are there any situations in which this won't work? I read on selfhtml.org (http://de.selfhtml.org/html/kopfdaten/meta.htm#weiterleitung, sry for the german link couldn't find another) that this isn't always appropriate. Are there any better ways to do this? And in which situations my code wouldn't work?


Solution

  • Well, the major argument against is what the linked page already says: The user's browser could have meta redirects turned off (although this is going to be rare), and immediate redirects can cause usability problems when the user tries to navigate through the history.

    If you can, though, don't output any HTML at all, but do a server-side redirect using the location header. In PHP, it would look like this:

    <? header("Location: http://www.xyz.com");
       die();
    ?>
    

    if you can't do that, I'd say using a meta redirect is fine. You could add a few seconds' pause and a message ("You are now being redirected to...."), combined with a link, to minimize annoyance for users.

    As for Search engine optimization, Search engines, I expect, will silently ignore the redirecting page, and go on indexing the target site, which is probably what one wants.