Forum Moderators: phranque

Message Too Old, No Replies

I rewrote the urls using mod_rewrite

Now there is no such thing as a 404 page?

         

MrSpeed

1:10 pm on Sep 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On my site I rewrote the urls using mod_rewrite so the urls look like.
h*tp://widgets.com/blue-widgets/

If someone were to type a nonsense url into the address bar like h*tp://widgets.com/foo-widgets/ my page returns a "No records found message"

This is because in my PHP page I check the record count of the query if there are records I display them, if not I just say "no records found"

It's not a big deal unless unless I change the data in the database. It seems like the search engines will keep indexing orphaned pages nowadays.

Would it not be wiser to return a 404 error?

How would I do this? I believe I would need to buffer the response and then issue a 404.

How have others handled this?

jd01

1:38 pm on Sep 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since you are already checking for, and delivering a message in php if there is no information, better and easier to just set the header there.

if(!isset($result) OR empty($result)) { header($_SERVER['SERVER_PROTOCOL']." 404 Not Found"); exit(); }

For the full message, see this thread (Msg. #15 & #17):

404 URL's [webmasterworld.com]

Justin

MrSpeed

7:51 pm on Sep 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That is exactly what I needed. Thanks

I saw that thread a few days ago but did not go back to it after message 10 or so...