Ajax software
Free javascripts
↑
Main Page
define(‘DB_USER’, ‘seouser’);
define(‘DB_PASSWORD’, ‘seomaster’);
define(‘DB_DATABASE’, ‘seophp’);
// defines the number of products for paging
define(‘PRODUCTS_PER_PAGE’, 1);
// the geo-targeting file name
define(‘GEO_TARGETING_CSV’, ‘geo_target_data/GeoIPCountryWhois.csv’);
?>
8.
Add the following mod_rewrite rules to the
.htaccess
file in your
seophp
folder:
RewriteEngine On
# Redirect to correct domain if incorrect to avoid canonicalization problems
RewriteCond %{HTTP_HOST} !^seophp\.example\.com
RewriteRule ^(.*)$ http://seophp.example.com/$1 [R=301,L]
# Redirect URLs ending in /index.php or /index.html to /
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html)\ HTTP
RewriteRule ^(.*)index\.(php|html)$ /$1 [R=301,L]
# Rewrite keyword-rich URLs for paged category pages
RewriteRule ^Products/.*-C([0-9]+)/Page-([0-9]+)/?$ category.php?category_id=$1&
i
page=$2 [L]
# Rewrite keyword-rich URLs for category pages
RewriteRule ^Products/.*-C([0-9]+)/?$ category.php?category_id=$1&page=1 [L]
# Rewrite keyword-rich URLs for product pages
RewriteRule ^Products/.*-C([0-9]+)/.*-P([0-9]+)\.html$ /product.php?category_id=$1&
i
product_id=$2&%{QUERY_STRING} [L]
# Rewrite media files
RewriteRule ^.*-M([0-9]+)\..*$ /media/$1 [L]
# Rewrite robots.txt
RewriteRule ^robots.txt$ /robots.php
9.
Create
include/url_factory.inc.php
and add the following code. This file contains helper
functions that create links to product pages, category pages, and media files. You can also find a
function that does 301 redirects to the proper version of a URL if the visitor isn’t already there.
<?php
// include config file
require_once ‘config.inc.php’;
// redirects to proper category URL if not already there
function fix_url($proper_url)
{
// 301 redirect to the proper URL if necessary
if (SITE_DOMAIN . $_SERVER[‘REQUEST_URI’] != $proper_url)
{
266
Chapter 14: Case Study: Building an E-Commerce Store
c14.qxd:c14 10:46 266
Ajax software
Free javascripts
→