Question

I have a situation where some users may come to mistyped pages, from links, etc. In most situations I can determine the correct page that should be displayed, so I want to redirect to the correct URL.

Is a 301 Redirect appropriate in this case. 301 means "Moved Permanently", but in this case the document wasn't there in the first place. Is it legitimate to set a 404 Not Found header, then redirect to the correct URL?

Was it helpful?

Solution

I'd use 301. Moved permanently is appropriate in that it tells the accessed page is not there and never will be. If someone has a link to that page, they then know they should update the link.

OTHER TIPS

Beware of 301, as it means "permanently", e.g. even if you use that URL in the future, search engines might want to disregard it - as they "know" the content at that particular URL was moved "permanently".

Use 303 See Other if you want the redirect, or - better - display 404 and a friendly error-message that links to the preferred content.

I think bringing the user to a "did you mean" type of page would be my preference. If you have no suggestions for the "did you mean" content, then give them a real error page and 404 it. Otherwise, leave the pages as status 200 and let the user click through.

I tend to use 301s to redirect previously known and well-established URLs that have changed for some reason. The reason I would worry about the automatic redirect approach is that a flaw in your detection algorithm could possible negatively impact SEO.

301 is perfectly appropriate when you are reasonably sure you know what the URL was supposed to be. It's the best solution both for browsers and for SEO when faced with broken incoming links.

However 3xx is inappropriate as a general page-not-found response. There are some sites that always 302 you to / instead of returning 404, but this is a really bad thing that can easily break stuff.

I know a 404 can include a redirect header but that sounds really bad to me.

you can't redirect with a 404 document. maybe just display a 404 page and suggest some correct URL's. 404 means error. I know google won't be happy seeing those links. :)

You can only respond once to an http request - you can't send a 404, and then send a 301. So you are stuck with the 301, I think.

Either use a 301 and do the redirect, or use a 404 and display a message along the lines of "I think you mean 'this URL' instead; update your bookmarks" (and don't redirect).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top