panthro panthro - 1 year ago 79
HTML Question

Code for temporary removal?

I know a 301 redirect is for a permanent change, and 302 is for a temporary change.

What code should I use when the page is offline for a number of weeks and in the mean time I am redirecting to the homepage? The page should be back up in a few weeks.

Answer Source

If you want to redirect, it would be 302. If you don't want to redirect, you could send 503 Service unavailable and set a Retry-After header (which should hopefully prevent search engines from coming back before that time).

If you still want the end-user experience to be a redirect to the homepage, you might, with heavy heart, consider adding that to the content of your 503 error page with a meta refresh or something JavaScript based, and hope for the best in terms of what a search engine crawler makes of that.

Previous answers suggest that browsers might honour cache and expires headers set on a 301 response, but since that fails-unsafe, I wouldn't rely on it. (The standard says the response is "cacheable unless indicated otherwise"; its definition of 302 Found suggests a 302 that is explicitly cacheable might be cached, but it wouldn't be the first time browsers don't implement what could be read out of the letter of the RFCs.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download