17 ms·
Make your 404s into 302s
- romanr 6y agoI’ve read all the pages on that site and still don’t understand. And probably can be explained in one sentence by someone?
- sunaurus 6y agoThe idea is to keep all old versions of your website, and when somebody requests an URL, try to find that URL on all versions of your websites (starting with the newest), and only return 404 not found if the URL does not exist on any of the archived versions.
- deleted 6y ago[deleted]
- Signez 6y agoYou are not alone there. I tried multiple times to understand what the author tries to convey, without being really sure to grasp it. At first I thought that it was simply some advocacy for taking the time to route legacy content using 302, but it also seems to be some sub-domain trick with years…? It's really confusing to me.
- spydum 6y agothink of it like having your 404 handler redirect to older versioned links maybe?
- Evansbee 6y agoDon’t 404 links on your new site, 302 redirect to previous versions on different hosts until you run out, then 404.
- phist_mcgee 6y agoIn a nutshell it is simply allowing you the ability to present fallback content with 302s but with a more gentle redirect than a 301, which tells you it is permanently gone.
- tartrate 6y agoI didn't either, but now I do. The site is suggesting a best practice to 302 FOUND-redirect you from: <version x>.site.com to: <version x-1>.site.com Until it goes beyond the oldest version in which case you end up with a 404.
- sokoloff 6y agoI’d like to be able to show any eventual 404 from the current version of the site though, which means there may need to be a wrapper around the terminal site (or more reasonably, code that runs locally on the server to find the right page URL and 302 directly to that rather than a client round trip for every version searched).
- deleted 6y ago[deleted]
- tarkin2 6y agoIt is poorly explained. I had to read the about page. Instead of 404s, you redirect to a previous version of your webserver (that is still running), which then instead of 404s redirects to a previous version of your site (that is still running), and eventually it tries the wayback machine. So never pull down a previous version of your website, and issue 302s to that?
- seodisparate 6y agoIt looks like they want websites to do the following: whenever your website goes under a drastic change, serve the previous version of the website under a subdomain, and redirect all 404s on the newer version to the subdomain. More drastic changes in the future may potentially redirect 404s to previous subdomains/versions like a chain. At least that's my understanding of it.
- LudwigNagasena 6y agoWhen you refactor your site, you put old content onto a subdomain and redirect there in case your new site doesn't have such page.
- deleted 6y ago[deleted]
- Faaak 6y agoThe idea is interesting and even kind of tech-funny. But man, you really have to explain how it works a bit better. At first I thought that we should redirect 404s to your website and I was: "??". What I understood: Which each iteration of the website, you archive the old one on a specific subdomain. Then, you redirect all 404s of the new website to the old one. Like that: no link is broken.
- ccurrens 6y agoYeah, I didn't understand and jumped straight to the comments to see if there was an easy explanation here. Guess I should have clicked "How?" at the top. https://4042302.org/how/ https://4042302.org/how/
- jessriedel 6y agoEven after reading that page, I didn't understand that this was a suggestion to start regularly archiving old versions of the site and only sending visitors there if their link didn't point to anything on the current site. Instead, I thought the idea was that, for software reasons I don't understand, web developers commonly changed the subdomain name for the main site and this was just a method for reducing the number of broken links when such a change was made. 4042302.org definitely needs better explanations.
- leethargo 6y agoAgreed, I thought this is a service that would provide automatic redirects to the Archive or similar.
- deleted 6y ago[deleted]
- Heliosmaster 6y agoFWIW Brave does that. If you reach a page with a 404 a banner will appear on top with a button to try and navigate to the latest version of the page you're looking for at the archive.
- throwaway2048 6y agoIf the redirect chain gets too long browsers will just give up and stop redirecting.
- torh 6y agoThat has happened to me, trying to log into Microsoft partner network. Guess they didn't like Chrome, because it worked when using IE.
- simias 6y agoThe home page is slightly misleading, the nginx config is of course the easy part, the hard part is to correctly archive all the previous versions of your website every time you make a change. I thought this website provided an archival service but it does not. People who care enough about preserving history and current links probably already do that. People who don't care aren't going to start now because of this page. Especially those who have dynamic content and probably don't want to keep running a million different versions of their backend forever. If you like something on the web then make a copy.
- ajphdiv 6y agoA better solution might be to start the archiving process from the beginning. Having a main page that links to content stored on 2020.website.com. The following year, publish new content on 2021.website.com, etc.
- vorpalhex 6y agoDoing this as a consumer and doing this as a webmaster are different processes. As a webmaster, if it's at all possible to go static (whatever your flavor of that is), then do that. A static website is easy to host and keep forever, and it's usually easy for consumers to archive too. Not to hate on PHP, but keeping older PHP sites around securely has become a major undertaking. You can't safely run a wordpress site that hasn't been updated in 5 years because your security vulnerabilities are exposed to the wide web. If your static site generator has security flaws.. well that doesn't affect your current build artifacts and you can still run the thing in secure ways.
- deleted 6y ago[deleted]
- tomaskafka 6y agoThe hard thing isn't the redirect, the hard and expensive thing is finding where to redirect.
- Macha 6y agoSo I'm aware of at least BBC using this approach, where opening really old articles reveals they have their 90s site still up. I'm also aware of at my last employer, an unmaintained wiki with open security issues that nonetheless had vital information for still in use legacy internal software was replaced by saved static HTML grabs so the information wasn't lost. But for a lot of medium sized companies with dynamic websites, this isn't always practical. They may not have the know how to dump their 2000s drupal install to static HTML files, and don't have the IT staff to upgrade and secure it.
- WJW 6y agoI wish people would would change their language regarding tech debt. The companies of your second paragraph choose not to upgrade and secure their websites. It's not something unavoidable.
- indigo945 6y agoThey point your parent poster is making is that these companies instead choose to shut the website down, which is a legitimate alternative to updating and securing it -- unlike just leaving it up without maintenance, which is not.
- WJW 6y agoThat's why I specifically indicated the companies referred to in the second paragraph of the parent post. The BBC and the unnamed company where Macha was working did it correctly.
- jpswade 6y agoThe BBC's approach to this has so far worked out as the best here and continues to provide its the correct approach. I think there's always been a lot to be said for good, static sites, and there still is.
- deleted 6y ago[deleted]
- badrabbit 6y agoI thought this was about a service that tries to find the right url and redirect back to your site at first. That would be a nice idea, like a spell correcting url finder for GET requests.
- LeonM 6y agoThere was a post here that was deleted by the author before I could write my reply. But he ended his comment with this: > You know why the web is broken? Because nobody cares. I agree with this. 404s aren't a technical problem, they are a maintenance problem. If there was time, budget or interest to fix it, the 404 wouldn't have existed in the first place.
- onion2k 6y ago404s aren't a technical problem, they are a maintenance problem. If there was time, budget or interest to fix it, the 404 wouldn't have existed in the first place. Doesn't that assume that all things on the internet are permanent? Why should that be the case? If I have a page on my website and I decide to delete it then I should be able to do that. Having links that pointed to it return a 404 is correct. 404s are useful. They convey real information. Sites that do things like 302 redirection to the home page when the link is apparently incorrect are annoying - you can never tell if the page is really gone or if the website has incorrectly bounced you to the home page.
- minikites 6y ago>410 Gone >Indicates that the resource requested is no longer available and will not be available again. This should be used when a resource has been intentionally removed and the resource should be purged.
- onion2k 6y agoOk, that would be a better response. The point still holds true for things that a link is pointing at but aren't found for other reasons though - for example, if a storage server has failed.
- cxr 6y ago> The point still holds true for [...] if a storage server has failed Still no. That kind of thing calls for a 5xx error.
- fizzizist1 6y ago404s are useful though.. how annoying would it be if you wanted to get to a specific part of the site, and you kept getting redirected to somewhere else without being informed that the part you are trying to access doesn't actually exist. 4 errors exist for a reason.
- m-p-3 6y agoOr sometimes a page stopped existing for a valid reason, and retrieving an old page that contains outdated information could do more harm than good.
- owl57 6y agoIn an ideal world, a page that stopped existing for a reason would be replaced by some text about that reason, not a generic "there's nothing here".
- _-___________-_ 6y agoThis would be best conveyed by a 410 Gone response with explanatory text about the reason in the response body.
- gravitas 6y agoThese ideas don't scale though - a 404 handles everything, not just textual content pages (meaning like images, css, js, etc. - the underlying plumbing for most sites). Nobody is going to sit there and write 404/410 content for moved assets one by one when they rebrand their site, that's madness. In my travels, most folks who actually care about this (SEO links) build an extensive alias/redirect map for the old/previous core URLs they want to remain functional as part of their rebrand, when the new site goes live the redirects are dropped in as well. This is especially true if they've ever published the URLs on physical media (mailed postcards, e.g.).
- cxr 6y ago
- swiley 6y agoIsn’t 302 the permanent redirect? You’re kind of giving up that URL on that domain forever then.
- _-___________-_ 6y agoNo, 302 Found is the usual redirect, which is not permanent but also not explicitly temporary.
- throwanem 6y agoIt is explicitly temporary. https://tools.ietf.org/html/rfc7231#section-6.4.3 https://tools.ietf.org/html/rfc7231#section-6.4.3
- _-___________-_ 6y agothanks, TIL!
- deleted 6y ago[deleted]
- pbhjpbhj 6y agoYou're thinking of 301. https://en.m.wikipedia.org/wiki/List_of_HTTP_status_codes https://en.m.wikipedia.org/wiki/List_of_HTTP_status_codes
- naringas 6y ago"but what about SEO?" --boss' first question
- phh 6y agoAfter a very quick overlook I thought it was 302-ing to archive.org. I'm almost sad this isn't the case.
- gmuslera 6y agoIt have a very specific use case, and will keep giving a strong visibility to the old, unmaintained site, for people that had old links to it. A more comprehensive 404 page (that says that what what you were looking for is not there, and links to the current and the old site), or redirects for the most accessed URLs of the old site in the new one are better approachs in my opinion.
- throwanem 6y agoThis is a good idea, but a bad design. First, it unduly burdens the server, in sending multiple redirects to cover the entire search space of possible versions of a URL - for a mature site, this could be a lot of redirects. It also unduly burdens the client, in following them, and the network between the two. Second, 302 is the wrong type of redirect to use here, because it is temporary; a well-tempered user agent will treat it as such, necessitating the same cascade of redirects on followup visits. The right way to do this is with a 301, which has a semantic of permanency, and is treated as such by user agents. But it's still the wrong thing to do. Maintaining access to older versions of websites is, again, an entirely desirable thing to do. But if you're going to do it in a way that requires work on the server (as this design also does), you're better off just having the server maintain version information and serve the latest available page at a given URL, in a 200 response, when the URL is accessed.
- mudita 6y agoI don't have any opinion on whether 302 or 301 is the better choice, I'd just like to point out that using 302 seems to have been a deliberate decision: from https://4042302.org/how/ https://4042302.org/how/ : >We use a 302 and not a 301 (permanent redirect) because we want the latest site to have the chance to override the URL in the future.
- Jaruzel 6y agoGoogle treats 302s and 301s differently when it crawls. A 302 is effectively ignored and the search index isn't updated - the original URL that threw the 302, is left in. Whereas 301s result in the new redirect target URL replacing the original in the search index. By filling up your sites with nested 302s (following this to it's conclusion, in ~10 years time), is not only a management headache, but may fall foul of Google (I'm not sure nested 302s, will send positive signals to Google) and result in your whole site being de-indexed.
- deleted 6y ago[deleted]
- veselin 6y agoThis is as good as the CVS versioning on a per-file basis. Its problems are well known and it is not widely used now for a reason.
- rafaelturk 6y ago1997 version is the best!
- germs12 6y agoThis is neat but hosting costs could be a burden.
- aidenn0 6y agoIf you crawl the old version of the site and save off static html, then the hosting costs would be minimal. If you added a banner at top saying it's "archived content" then that would also solve the issue with people being confused by the redirect that other comments have had.
- djhworld 6y agoOn a similar note, my blog is hosted on github pages. Due to laziness and inertia I've kinda just left it there as it just works, but the lack of control makes me uneasy. So at some point I want to move it, hosted by myself (with CDN) and under my own domain. Except all the links that people have used to link to my GH pages blog are still out there and I'm not sure how to cleanly redirect visitors to my own hosted version of the blog. window.location hack? Has anyone else done this (I appreciate my lack of foresight on my behalf is a problem of my own making...)
- karagenit 6y agoWell, if it stays as a static site, you could always set your server to push any changes to GitHub as well, so you effectively keep your GitHub pages site up as a mirror of your personal domain. You could also make all of your navigation links absolute links that redirect to your new domain. Or, like you suggested, make a skeleton site out of the current version of the site where each page just has a bit of JS to redirect a visitor.
- pbhjpbhj 6y agoOr use a meta "redirect", https://stackoverflow.com/questions/5411538/redirect-from-an-html-page https://stackoverflow.com/questions/5411538/redirect-from-an..., assuming they are able to write to the head-tag.
- fenwick67 6y agoIf you set up a custom domain in github pages, it will redirect to it automatically, even if the page doesn't exist. https://fenwick67.github.io/some/dir/ https://fenwick67.github.io/some/dir/ automatically redirects to https://fenwick.pizza/some/dir/ https://fenwick.pizza/some/dir/ .
- moimikey 6y agoHave to agree with all of the disagreements to this. The 404 is a 404 for a reason, just like 301 and 302 are different for a reason. It's not uncommon though for WordPress to do things like this, or blogs for that matter. If an author changes the title or date of their post, and the URL structure is reliant on those two pieces of data, then the URL will change. The old URL is preserved in a DB and if accessed again, 301s to the newly named resource. Others, will throw a 404 and give a cutesey Levenshtein message, "did you mean x?" at which the user can decide to go to the new resource. It's all circumstantial... It shouldn't be enforced. Re: Google and PageRank, pretty certain they've addressed this and recognize 302 and 301s and treat them the same. Previously, this was an issue.
- C1sc0cat 6y agoLooks like the op is trying to solve a problem of broken links but has come up with a "brave choice" as they say on yes minister. The actual solution is put in the work and redirect the old missing page to a relevant new one. If I had a link from vogue the BBC etc back in 1996 point to a product page to want to redirect that now broken link with a 301.
- bfred_it 6y agoI recently dropped my last shared hosting in favor of Vercel/Netlify and some content was lost. This solution wouldn’t work for me because the very reason why the content was lost is that I don’t want to pay for hosting I barely use. A better solution would be an intermediary part that never changes — say, CloudFlare — that caches HTML pages forever, automatically adds a “Archived content” header to the page, and warns the author so that they can either allow the archived version or make it a 404/410 instead. Nobody wants to maintain servers forever, but serving static/frozen pages is much easier and cheaper.
- globular-toast 6y agoI remember learning one of the golden rules of the Web is you don't break links. It's a shame it's regressed this far. Now it's normal to get many 404s every day. Shouldn't it be 301 rather than 302, though?
- codingdave 6y agoIf I'm reading this correctly, this concept work only if you never take down old sites, and you have a full archive.org copy out there. This is not realistic for large SaaS apps. I run a SaaS app that has been online for over a decade, with millions of public documents. While we do strive to minimize URLs changes, and we do have robust redirects in place for old URL formats... it is simply not feasible to keep old versions online.
- jonnypotty 6y agoAt least you can look up what 404 means and reason about what's going on. What does this change solve? I mean if you moved your site then you would issue a 301 from the old host showing people it had moved. I don't know when exactly people make lots of different versions of the same website where it makes sense to fail over to the old one if the new one doesn't work. Baffling
- Jaruzel 6y agoHow I've tackled this problem in the past: 1. Create a 404.php (or whatever your preferred back-end is) 2. mod_rewrite real 404s to serve that script. 3. In that script have a lookup table/db/file that lists all the redirects you need. 4. Extract the requested URL from the server variables. 5. Use the lookup table to find the correct URL, and issue a 302 for it to the users browser. It's kinda seamless, and I've been doing it for years.
- ogre_codes 6y agoI've maintained link integrity for a long time on my personal site using a similar tactic, however for me anyhow the new Wordpress version of the site had very little URL overlap with the old version so I just converted the old PHP version to static HTML and and set up nginx to serve both. When I migrate off WordPress, I expect I'll maintain a similar approach. No reason to maintain an older version of the site which could have security issues.
- ptsneves 6y agoMy apologies if I am repeating what others have said, but just yesterday I chose to give a 404 for an operation that could not be concluded because a resource is not available. A 404 is not about pages but about resources. It is perfectly legitimate that a resource is not available anymore or is temporarily down in a non internal error kind of way. A REST request on a IoT device can return 404 if the device is not available at the moment. Any redirect is meaningless and actually breaks the semantics of 404. My understanding is that 404 has been so connected with the file like persistent resources, that people forgot the elegance of the wording in the standard. I can understand the popular usage change, but I think then the standard actually becomes incomplete because it only fits web pages or document type resources when an HTTP status code is about Hyper text Transfer Protocol. Alternate view disagreeing with what postulated above is that, actually HTTP has been abused and is being used in scenarios that have nothing to do with Hyper Text, looking at you JSON REST :D
- jrockway 6y agoI don't think 404 is the right code for "resource not available". If you want to send a request to a device, and it's not online, that is "503 Service Unavailable". The device exists, after all, it just isn't available to handle the request. Ultimately, HTTP has a very weak set of status codes for application layer concerns. The vast majority of the ones that sound good mean something about the HTTP layer rather than the application layer -- for example, it makes sense to return "precondition failed" if you request deletion of a directory that isn't empty (the precondition for deleting directories is that they are empty), but "412 Precondition Failed" means that the client supplied an HTTP precondition like "If-Match: abc123" and it failed. Trap for the unwary. For this reason, I think REST largely fails to provide what API authors and users desire. If your API server can successfully convey an error to the client, you might as well say '200 OK {"error": "The Raspberry Pi you were looking for exists, but it's turned off or someone used its Ethernet cable to test their scissors and the test went very well."}' Now the client actually knows what's going on.
- ptsneves 6y agoThe Ethernet cable scissor test success made me laugh :D. We agree on the general weak suitability of http codes to convey application layer status, but I kind of disagree on the 503 because it implies an overload and an internal error, which is not the case. Also I really believe the resource not a available is as accurate as it gets. In the end I agree with you we may be splitting hairs with a very unsuitable status report and should just send 200 with the error. I have done this before actually, but it tickles my neck a lot to see an OK, then error.
- StavrosK 6y agoThis is a good idea, but I'm afraid it's rather unworkable in practice. If you're going to remove a page, you either didn't want it up, or you moved it somewhere else, or your entire site is unavailable. If you moved it somewhere else, you should add a 301, but for all other cases it's not for lack of will that the link died. The nice thing about IPFS is that it has this out of the box. Pages can never die as long as at least one node has them in their cache, even if the original owner went away.
- at_a_remove 6y agoRemember "Cool URIs Don't Change"? I think about it a lot. It was written toward the end of the BOHF's reign, when a technical specialist of the web had quite a lot of sway, when their decisions about a site's information architecture and how it was run was, if not the law, at least a very heavy hand on the till. Those days are long past. Now Ted in Marketing wants a URL and who are you not to give it to him? I remember the pain of creating vanity top-level URLs in SharePoint 2003 because some functionary wanted them, and then they would promptly forget what they demanded. Yes, I used to use 410 Gones where appropriate. That sort of thing has not been in our hands for quite a white, even if it is probably the best thing to do. After all, has the product URL changed? Or will it be back? Or has it been discontinued? The correct HTTP response, properly and widely used, would be very helpful in moving so much of the web forward but that is not under our control. Hasn't been for a while.
- lalos 6y agoClever usage of subdomains
- based2 6y agohttps://1997.4042302.org/whatdidyoudo https://1997.4042302.org/whatdidyoudo Is it a 404?
- hardekore 6y agoi laugh at how you new web guys sell something ancient as new hot shit. catching 404s, sending 302 and thus passing google juice to another url is nothing new.