Questions tagged [http-status-code-404]

The HTTP status code 404 or "Not Found" indicates the server could not find the requested file or resource.

A 404 often means that the URL requested is invalid or points to a file that no longer exists (e.g. has been moved or deleted). It can also mean that web service method or other similar resource does not exist.

Many web servers can be configured to display a specific error page when this occurs which allows users to continue navigating in a manner consistent with the design of the website.

See RFC2616 for reference.

Microsoft's Internet Information Services (IIS) versions 7, 7.5, and 8.0 provide additional sub-status values for various types of 404 response statuses. These are not recognized as standard status codes, but may be relevant for IIS-hosted applications.

Microsoft Sub-Status Codes:

404.0 – Not found.
404.1 – Site Not Found.
404.2 – ISAPI or CGI restriction.
404.3 – MIME type restriction.
404.4 – No handler configured.
404.5 – Denied by request filtering configuration.
404.6 – Verb denied.
404.7 – File extension denied.
404.8 – Hidden namespace.
404.9 – File attribute hidden.
404.10 – Request header too long.
404.11 – Request contains double escape sequence.
404.12 – Request contains high-bit characters.
404.13 – Content length too large.
404.14 – Request URL too long.
404.15 – Query string too long.
404.16 – DAV request sent to the static file handler.
404.17 – Dynamic content mapped to the static file handler via a wildcard MIME mapping.
404.18 – Query string sequence denied.
404.19 – Denied by filtering rule.
404.20 – Too Many URL Segments.

6856 questions
516
votes
12 answers

How to redirect to a 404 in Rails?

I'd like to 'fake' a 404 page in Rails. In PHP, I would just send a header with the error code as such: header("HTTP/1.0 404 Not Found"); How is that done with Rails?
Yuval Karmi
  • 26,277
  • 39
  • 124
  • 175
446
votes
19 answers

How can I properly handle 404 in ASP.NET MVC?

I am using RC2 Using URL Routing: routes.MapRoute( "Error", "{*url}", new { controller = "Errors", action = "NotFound" } // 404s ); The above seems to take care of requests like this (assuming default route tables setup by initial…
Brian
  • 4,494
  • 3
  • 17
  • 7
427
votes
14 answers

Why is @font-face throwing a 404 error on woff files?

I'm using @font-face on my company's site and it works/looks great. Except Firefox and Chrome will throw a 404 error on the .woff file. IE does not throw the error. I have the fonts located at the root but I've tried with the fonts in the css folder…
dcp3450
  • 10,959
  • 23
  • 58
  • 110
166
votes
15 answers

Easy way to test a URL for 404 in PHP?

I'm teaching myself some basic scraping and I've found that sometimes the URL's that I feed into my code return 404, which gums up all the rest of my code. So I need a test at the top of the code to check if the URL returns 404 or not. This would…
bflora
158
votes
10 answers

How to create an error 404 page using PHP?

My file .htaccess handles all requests from /word_here to my internal endpoint /page.php?name=word_here. The PHP script then checks if the requested page is in its array of pages. If not, how can I simulate an error 404? I tried this, but it didn't…
Eric
  • 95,302
  • 53
  • 242
  • 374
150
votes
12 answers

How to get MVC action to return 404

I have an action that takes in a string that is used to retrieve some data. If this string results in no data being returned (maybe because it has been deleted), I want to return a 404 and display an error page. I currently just use return a…
Paul Hiles
  • 9,558
  • 7
  • 51
  • 76
145
votes
20 answers

Django, creating a custom 500/404 error page

Following the tutorial found here exactly, I cannot create a custom 500 or 404 error page. If I do type in a bad url, the page gives me the default error page. Is there anything I should be checking for that would prevent a custom page from showing…
reZach
  • 8,945
  • 12
  • 51
  • 97
141
votes
16 answers

Why won't my PHP app send a 404 error?

if (strstr($_SERVER['REQUEST_URI'],'index.php')) { header('HTTP/1.0 404 Not Found'); } Why wont this work? I get a blank page.
Yrrol
138
votes
28 answers

react.js Replace img src onerror

I have a react component that is the detail view from a list. I am trying to replace the image with a default image if the image does not exist and there is a 404 error. I would normally use the onerror method in the img tag but that doesn't seem…
Joel Lawler
  • 1,409
  • 2
  • 10
  • 8
126
votes
13 answers

How do I return NotFound() IHttpActionResult with an error message or exception?

I am returning a NotFound IHttpActionResult, when something is not found in my WebApi GET action. Along with this response, I want to send a custom message and/or the exception message (if any). The current ApiController's NotFound() method does not…
Ajay Jadhav
  • 2,417
  • 4
  • 21
  • 26
122
votes
10 answers

Routing for custom ASP.NET MVC 404 Error page

I am trying to make a custom HTTP 404 error page when someone types in a URL that doesn't invoke a valid action or controller in ASP.NET MVC, instead of it displaying the generic "Resource Not Found" ASP.NET error. I don't want to use the web.config…
119
votes
6 answers

What is a simple/minimal browserconfig.xml for a web site

I don't want to do anything special or tricky with respect to Windows 8 and pinning, I just don't want to see the 404 Not Found messages as IE looks for browserconfig.xml scrolling by in my log files. Is there a trivial browserconfig.xml file that I…
drchuck
  • 4,415
  • 3
  • 27
  • 30
118
votes
19 answers

Servlet returns "HTTP Status 404 The requested resource (/servlet) is not available"

I have an HTML form in a JSP file in my WebContent/jsps folder. I have a servlet class servlet.java in my default package in src folder. In my web.xml it is mapped as /servlet. I have tried several URLs in action attribute of the HTML form:
pongahead
  • 1,984
  • 3
  • 18
  • 21
113
votes
7 answers

Vue-router redirect on page not found (404)

I'm trying to redirect to 404.html on page not found using the router.beforeEach global hook, without much success (using Vueand Vue-Router 1.0): router.beforeEach(function (transition) { if (transition.to.path === '/*') { …
nunop
  • 2,036
  • 2
  • 20
  • 36
111
votes
7 answers

Returning a 404 from an explicitly typed ASP.NET Core API controller (not IActionResult)

ASP.NET Core API controllers typically return explicit types (and do so by default if you create a new project), something like: [Route("api/[controller]")] public class ThingsController : Controller { // GET api/things [HttpGet] public…
Keith
  • 150,284
  • 78
  • 298
  • 434
1
2 3
99 100