Mod_rewrite - How to tell Google to dynamically remove pages from its index after 7 days
Search engines love to crawl and index web pages or URLs, but what if your web pages / URLs have expired content and you don't want to be indexed after a few days?
Can you put an expiration in the url and have mod_rewrite 301 redirected pages after a given expiration date?
Or maybe a cron job to add a 301 redirect header to all expired pages?
a source to share
Not 404 or 301, but 410 Gone . This is the relevant HTTP response:
The requested resource is no longer available on the server and the forwarding address is not known. This condition is expected to be considered permanent. Clients with link editing capabilities SHOULD remove references to the Request-URI upon user approval. If the server does not know or has no way to determine if this condition is persistent, the 404 (Not Found) status code should be used instead. This response can be cached unless otherwise noted.
Answer 410 is primarily intended to help maintain the website by notifying the recipient that the resource is intentionally unavailable and that the server owners wish to remove the remote links to that resource. Such an event is common for limited time, advertising services and resources owned by individuals who no longer operate on the server. There is no need to mark all permanently unavailable resources as "gone" or keep the mark for some time - this is at the discretion of the server owner.
As you report, this answer is open to discussion. There are many ways.
a source to share