How do I force redirect all 404’s (or every page, whether invalid or not) to the homepage?

Setting the error page to the home page like this error_page 404 /index.html; has a small problem, the status code of the home page will be “404 not found”, if you want to load the home page with a “200 ok” status code you should do it like this error_page 404 =200 /index.html; This will … Read more

ASP.net HTTP 404 – File not found instead of MaxRequestLength exception

I experienced this condition today (HTTP 404 on large file upload with IIS 7) but I thought I had made all the correct configuration settings. I wanted to upload files up to 300MB so I made the following web.config settings in a sub-folder of the application: <configuration> <system.web> <httpRuntime maxRequestLength=”307200″ /> </system.web> <system.webServer> <security> <requestFiltering> … Read more

How to let react router respond with 404 status code?

With react-router 2.0.0 you can do: <Route path=”*” component={NoMatch} status={404}/> EDIT: What you would need to do, is to create a custom attribute on your route definition, like you can see above (status). When you are about rendering you component on server side, check on this attribute and send a response with a the code … Read more

How to make a catch all route to handle ‘404 page not found’ queries for ASP.NET MVC?

Found the answer myself. Richard Dingwall has an excellent post going through various strategies. I particularly like the FilterAttribute solution. I’m not a fan of throwing exceptions around willy nilly, so i’ll see if i can improve on that 🙂 For the global.asax, just add this code as your last route to register: routes.MapRoute( “404-PageNotFound”, … Read more

using javascript to detect whether the url exists before display in iframe

Due to my low reputation I couldn’t comment on Derek 朕會功夫’s answer. I’ve tried that code as it is and it didn’t work well. There are three issues on Derek 朕會功夫’s code. The first is that the time to async send the request and change its property ‘status’ is slower than to execute the next … Read more

How can I return a 404/50x status code from a Grails Controller?

Setting the response status with its own statement is good enough. It doesn’t look too ugly and is pretty straightforward: response.status = 404; I’ve used this successfully myself and have seen others do it this way too. Since it’s just a setter, you can also do other stuff after setting the status. Whichever status you … Read more

HTTP Status 404 – The requested resource (/) is not available

What are you expecting? The default Tomcat homepage? If so, you’ll need to configure Eclipse to take control over from Tomcat. Doubleclick the Tomcat server entry in the Servers tab, you’ll get the server configuration. At the left column, under Server Locations, select Use Tomcat installation (note, when it is grayed out, read the section … Read more