Prev | Current Page 315 | Next

Emilian Balanescu and Cristian Darie

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

php by adding the highlighted code:
/* Remove the virtual location from the requested URL
so we can compare paths */
$requested_url = self::Build(str_replace(VIRTUAL_LOCATION, '',
$_SERVER['REQUEST_URI']));
// 404 redirect if the requested product, category or department
// doesn't exist
if (strstr($proper_url, '/-'))
{
// Clean output buffer
ob_clean();
// Load the 404 page
include '404.php';
// Clear the output buffer and stop execution
flush();
ob_flush();
ob_end_clean();
exit();
}
// 301 redirect to the proper URL if necessary
if ($requested_url != $proper_url)
{
2. Open presentation/products_list.php, and add the following code to the init() function:
elseif (isset($this->_mDepartmentId))
$this->mProductListPages[] =
Link::ToDepartment($this->_mDepartmentId, $i);
else
$this->mProductListPages[] = Link::ToIndex($i);
}
/* 404 redirect if the page number is larger than
the total number of pages */
if ($this->mPage > $this->mrTotalPages)
{
// Clean output buffer
ob_clean();
// Load the 404 page
include '404.php';
CHAPTER 7 ?–  SEARCH ENGINE OPTIMIZATION 217
// Clear the output buffer and stop execution
flush();
ob_flush();
ob_end_clean();
exit();
}
// Build links for product details pages
for ($i = 0; $i < count($this->mProducts); $i++)
{
3. In your tshirtshop folder, create a file named 404.php, and type in the following code:
// Set the 404 status code
header('HTTP/1.


Pages:
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
Toruń hotele certyfikaty energetyczne poznań sypialnia mieszkania sosnowiec pieniny noclegi