The PHP way of performing
the redirection is by setting the HTTP header like this:
// 301 redirect to the proper URL if necessary
if ($requested_url != $proper_url)
{
// Clean output buffer
ob_clean();
// Redirect 301
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $proper_url);
// Clear the output buffer and stop execution
flush();
ob_flush();
ob_end_clean();
exit();
}
We call CheckRequest() in index.php to make sure it checks all incoming requests.
We also altered index.php by adding output control code to ensure that we will be able to flush the output and
change the output headers whenever necessary, as the headers can??™t be changed after sending any output to the
client. Read more about the output control functions of PHP at http://php.net/outcontrol. A useful article
on the subject can be found at http://www.phpit.net/article/output-buffer-fun-php/.
Customizing Page Titles
One of the common mistakes web developers make is to set the same title for all the pages on
a web site. This is too bad, since the page title is, in the opinion of many SEO authorities, the
most important factor in search engines??™ ranking algorithm. This is confirmed by the article at
http://www.seomoz.org/article/search-ranking-factors.
Right now, all the pages in TShirtShop have the same title, which is defined in site.conf.
In the following exercise, you??™ll see that it??™s easy to update the site to display customized page
titles for each area of the site.
Pages:
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318