How to serve 410 from Apache rather than a 404

apache-2.2mod-rewrite

On our site, we tend to remove pages a lot where the content has expired, and we want to return http status 410 rather than 404 for requests to pages (physical files) that don't exist on our server (the entire site is made up of static files).

We have tried

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ - [G,L]

from this blog post but that just breaks our entire site, serving a 410 for every request.

We are using Apache 2.2.3

Best Answer

    Redirect gone /path/to/resource

Is the correct way to do it. If that's causing errors for you, make sure you have mod_alias loaded in the server.