Welcome to WebmasterWorld Guest from 50.19.34.234

Forum Moderators: phranque

Message Too Old, No Replies

Is it possible to write an HTML only 410?

     

bigtoga

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

10+ Year Member



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.

phranque

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

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



no.

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

lucy24

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

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



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".

g1smd

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

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.

not2easy

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

WebmasterWorld Administrator 5+ Year Member Top Contributors Of The Month



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.

bigtoga

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

10+ Year Member



Thanks everyone - helped a lot.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month