410 Gone
The 410 (Gone) HTTP status code indicates the requested resource previously existed on the server, but no longer does. It is handled the same way as 404 (Not Found), but serves to reassure users that the resource has not disappeared by mistake.
This status code is considered a 4xx client error because it is not a server error; the resource was deliberately removed and it is expected to be gone indefinitely.
Writing responses (servers)
This status code is a more specific variation of 404 Not Found which implies the resource previously existed.
If the resource was merely moved, servers should use 308 Permanent Redirect instead.
Implementing with a Database
Implementing the 410 status code is most straightforward with a database that has a "deleted" flag. See Database-backed applications below.
Implementing with a filesystem
The simplest way to keep track of individual files that have been removed is to register them in a .htaccess
file in the same directory (or similar file, if supported by your HTTP server), or else enter the file into the configuration file. See Implementations below for details.
Most users settle for returning a 404 response.
Reading responses (clients)
This is the expected error code after a resource has been deleted by a client.
Handling is similar to 404 Not Found, see that status code for handling details.
Overview table
- Name
- 410
- Message
- 410 Gone
- Description
- The resource was deleted and does not exist anymore
- Specification
- RFC 7231: HTTP/1.1 Semantics and Content ยง6.5.9. 410 Gone
Implementations
Database-backed applications
Resources backed by a database may include a "deleted" flag to indicate the resource should no longer be accessible. An example SQL query:
SELECT deleted, data FROM documents WHERE id=?
If there are no results, return 404
. If the "deleted" flag on the returned result is nonzero, return 410
. Otherwise, continue processing the result towards a 200 OK
response.
Apache httpd
With mod_rewrite enabled, you may list regular expressions to file paths that will return 410 with the server-default error page. This may be used in a .htaccess
file, if permitted by AllowOverride. The error document may be specified by ErrorDocument.
# G flag to set the status code to 410 Gone RewriteRule "index\.html$" "-" [G] ErrorDocument 410 /errors/removed.html
Nginx
Use a return
statement inside a location
block to match patterns of files:
location /file/ { return 410; }