homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque & physics

Webmaster General Forum

Is it possible to write an HTML only 410?

 3:21 pm on Jul 8, 2013 (gmt 0)

Apologies if this is covered elsewhere but I'm struggling to find it if it is. I have some old blogs that I'd like to 410 a few pages. These are .html pages and I'd like to just keep the filename the same (foo.html) but 410 it. I'm using IIS7. Javascript would be okay in the page though.

I know how to do this other ways but that's not what my question is about. Specifically I want to know if it is possible to generate a 410 with an HTML page.



 3:26 pm on Jul 8, 2013 (gmt 0)


by the time a user agent sees an html document, it's too late for a 4xx status code.


 4:13 pm on Jul 8, 2013 (gmt 0)

410 means the page is gone. If the URL resolves to a page that physically exists, it isn't a 410. The "gone" message has to be sent by the server before the request makes it to the page.

Theoretically a .php page (or other dynamic format) can send out a 410 just as easily as it can issue a 404 or a redirect. But generally you wouldn't bother unless you've removed a ### of a lot of pages in one fell swoop-- and they don't fit into a pattern your server can recognize, such as an entire directory.

The flip side in the case of html pages is that you don't have to do anything at all with the physical page file. The 410 message only gets sent out if you've explicitly coded it. The server never even looks for the page, so it neither knows nor cares if it's really there. Today's servers are not clever enough to say "this page was here yesterday and it's gone now, so I'll send out a 410 on my own initiative".


 7:33 pm on Jul 8, 2013 (gmt 0)

You can keep the filename the same, change the site configuration to parse .html files as PHP or as ASP and then add a few lines of scripting to the start of the .html file to return a different HTTP response code.

If the .html pages are generated by a CMS, then you need to alter the CMS scripting code to generate the alternative HTTP response code when those particular URLs are requested.


 12:47 am on Jul 9, 2013 (gmt 0)

g1smd has the answer I would use. If you are already using php includes in your html pages you can just replace the entire contents of the page with a few lines like:
Header( "HTTP/1.1 410 Gone" );

and save the html page with the same name it has always had. Google calls it a 410 and it is still a html page.

If you are not using php in your html pages you may need to check with your host for their recommended method to enable php parsing on html pages. The line I add to my .htaccess file may not work for your situation, but your host should be able to help, it is a very common practice.


 2:02 pm on Jul 9, 2013 (gmt 0)

Thanks everyone - helped a lot.

Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved