Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

Set up 404 or 301 for deleted dynamic pages

         

helenp

6:48 am on Jun 7, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi,
Maybe this should go in another section, but not sure where, anyway google WMT told me I had a page without title, so I checked out why and wich.

Have not worked with dynamic pages before.
I have some dynamic pages that were deleted from the database, of course did not thought that google will find the page even if its not in the database anymore and no more internal links.
Often pages may be removed and I am not fancy about using htaccess every time I delete a page so I guees if there are links to the page I should do a 301 otherwise I should do a 404, but how can I do so?
using htaccess only, or maybe I should add a value in database deleted and keep the "page" and add a 404 on page.
How does you handly this normally?
Thanks,

helenp

12:26 pm on Jun 7, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I understand the quesion was stupid and easy to resolve.
I just added an else
and in the else
else {
header("HTTP/1.0 404 Not Found");
exit;
}

If I open the page I dont see any 404 page,
however I get this response using a header check:
HTTP/1.0 404 Not Found =>
Date => Fri, 07 Jun 2013 12:24:12 GMT
Server => LiteSpeed
Connection => close
X-Powered-By => PHP/5.2.17
Content-Type => text/html
Content-Length => 0
Cache-Control => max-age=7200

Suppose somthing is wrong as should get an error page and not an empty page

helenp

3:29 pm on Jun 7, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I also have this to avoid duplicate http and https indexing,

how to have both the 301 and the 404?
I been trying and get a 400 bad request if I have it before the 404

if ($_SERVER['SERVER_PORT'] == 443)
{
$host = $_SERVER['HTTP_HOST'];
$request_uri = $_SERVER['REQUEST_URI'];
$good_url = "http://" . $host . $request_uri;

header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: $good_url" );
exit;
}

lucy24

8:52 pm on Jun 7, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If I open the page I dont see any 404 page

No, you have to add it in manually. (You can count on the fingers of one hand the things I know about php. This is one of them ;))

Normally your 403 or 404 page is requested by the server when, for example, it looks for a page and can't find it. But if it's happening within php, the server thinks everything is fine and dandy 200 good to go: it found the php page, so its job is finished.

If your php page can't convert the parameters into a real visible page, it has to do two things. One is the part you've already got: send the user a 404 response. The other thing it has to do is include your entire custom 404 page, as in

include ($_SERVER['DOCUMENT_ROOT'] . "/boilerplate/missing.html"


That's my specific URL, of course. If the php involved any output buffering, also get rid of the buffer-- _clean, not _flush --at this point. No, I don't know what happens if you close the php while there is still content in the buffer. But probably something messy.

helenp

9:34 am on Jun 8, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks Lucy,
I got the 404 static page, and I suppose my code was ok,
as I just found out I got as header 400 error on all pages if I use https instead of http, if you remember my pages has a redirection at beginning of all pages that states if http or https.
The redirection is done, but sends header 400.
Think google has dropped the duplicated pages.
I have written to my host about it, lets see whats happens.
Thanks