Next, open index.php, and add a reference to a nonexistent file:
// URL correction
Link::CheckRequest();
require_once('inexistent_file.php');
CHAPTER 7 ?– SEARCH ENGINE OPTIMIZATION 215
6. Now, load your application. If everything works as expected, you should get the 500 page shown in
Figure 7-7.
Figure 7-7. Testing the 500 page in TShirtShop
How It Works: Handling 500 Errors
As you can now see, if an application error happens, the visitor is shown a proper error page. The status code is
properly set to 500, so the search engines will know the web site is experiencing difficulties and won??™t index the
500 error page. Instead, the previously indexed version of your page, which supposedly contains contained the
correct content, is kept in the index. This is very important, because unless the 500 status code is used properly,
your entire site could be wiped out of the search engine index, by replacing all the pages with the text you can see
in Figure 7-7.
?– Note Before moving on to the next exercise, be sure to set the DEBUGGING constant back to true, so that
TShirtShop will show debugging data when an error happens, instead of throwing the 500 page. Also, remove
the reference to inexistent_file.php.
CHAPTER 7 ?– SEARCH ENGINE OPTIMIZATION 216
Exercise: Using the 404 HTTP Status Code
1. Modify the CheckRequest() method in presentation/link.
Pages:
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326