开发者

301/302 with document body showing 'click here if your browser doesn't redirect you' anchor

We will be implementing a tiny document body with all our 301 and 302 responses.

They will contain a small bit of html with an anchor pointing towards the URL where the user should be redirected.

Are there any pitfalls or things we should know about 开发者_如何学Pythonwhen doing this or is it as simple as including the html in the document body when sending out a 'location' header?


If browser will see 301/302 HTTP result code it will IGNORE document/response body and will do instant redirect to the URL specified in Location: response header.


But yes -- you can display such page and do redirect to a new URL .. but this will be the same as normal click on a link (and not 301/302 redirect in any means) and therefore is not good for SEO purposes. If interested -- this is how it can be done:

When user hits such page, show him/her your redirect message/page. In that page such redirect can be achieved in 2 ways:

  1. Using JavaScript -- window.location = "http://www.example.com/new-url". All what you need to do is to execute this code 10 seconds after page is loaded -- for that use setTimeout() functionality.

  2. Without JavaScript (preferred method as it will work even if JavaScript is disabled or not available) using <meta http-equiv="refresh" header line:

    <meta http-equiv="refresh" content="10; url=http://www.example.com/new-url">

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜