Prev | Current Page 305 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

1 301 Moved Permanently');
header('Location: ' . $proper_url);
// Clear the output buffer and stop execution
flush();
ob_flush();
ob_end_clean();
exit();
}
}
CHAPTER 7 ?–  SEARCH ENGINE OPTIMIZATION 205
4. Open index.php, and call this method like this:
// Load the database handler
require_once BUSINESS_DIR . 'database_handler.php';
// Load Business Tier
require_once BUSINESS_DIR . 'catalog.php';
// URL correction
Link::CheckRequest();
// Load Smarty template file
$application = new Application();
// Display the page
$application->display('store_front.tpl');
// Close database connection
DatabaseHandler::Close();
5. Load http://localhost/tshirtshop/natureTYPO-d2/, and notice that page redirects to http://
localhost/tshirtshop/nature-d2/. Using a tool such as the LiveHTTPHeaders Firefox extension
(http://livehttpheaders.mozdev.org/), you can see the type of redirect used was 301; see Figure 7-4.
Figure 7-4. Testing the response status code using LiveHTTPHeaders
CHAPTER 7 ?–  SEARCH ENGINE OPTIMIZATION 206
?– Note Other tools you can use to view the HTTP headers are the Web Development Helper and Fiddler for
Internet Explorer and FireBug or the Web Developer plug-in for Firefox.
How It Works: Using 301 for Redirecting Content
The code follows some simple logic to get the job done. The CheckRequest() method of the Link class verifies
if a request should be redirected to another URL, and if so, it does a 301 redirection.


Pages:
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317