开发者

Have old web site immediately redirect to new web site?

I need to redirect my old site to my new one so that it is a seamless transition fo开发者_Go百科r those who still visit the old one.

Thanks


Personally I'd show a "this site has moved to ..." message for a few seconds before redirecting, so people know to stop bookmarking the old site in case you want to drop it.

The actual redirect comes in three flavors:

  1. the redirect header: header('Location: http://newaddres') in php or Response.Redirect in asp.net. This is instantaneous because it's server side, the user won't see a temporary page and wait for it to load, but it won't let you display the message.

  2. html meta refresh: <meta http-equiv="refresh" content="5;url=http://newaddress">. Doesn't require javascript, can setup a delay to show your message, but isn't instantaneous. The client has to make a second request to the new site.

  3. javascript redirect: location.href='http://newaddress'. Obviously requires javascript or it won't work. Can still setup a delay with setTimeout. Overall the weakest method because web crawlers (like google) won't follow the link, nor will people with javascript disabled be able to see your site.

My vote is for #2 with a temporary message explaining the redirect. It's a great balance between not bugging the user much and eventually being able to safely drop the old site.


<html>
<head>
<script type="text/javascript">
  document.location.href = 'http://yournewwebsite.com';
</script>
</head>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜