CRE Loaded Search Engine Optimized URLs

Introduction

CRE SEO URLs transforms standard links in CRE Loaded into search-engine-friendly links to increase your store's position and popularity in search engines. Note that this is primarily of use to those in niche markets dependent upon specialized search engines that do not parse PHP urls well.

Installation instructions apply to default distributions of CRE Loaded 6.15 or 6.2.x only.  Support covers installation on these products, but not instructions on applying these changes to customized carts.

Minimum System Requirements

Existing Software:
CRE Loaded 6.15 or later.

Version Compatibility:
This version is compatible at the source-code level with the previous version (4.0). Older versions must be completely uninstalled before installing this code.

Installation

Before you can install this product, you must obtain access to a working installation of:

* CRE Loaded 6.15 or
* CRE Loaded 6.2.x

To install CRE SEO URLs:

1. Be sure that your hosting provider allows mod_rewrite directives in .htaccess.

If you are hosted with Chain Reaction Web [http://chainreactionweb.com], simply visit the Chain Reaction Web support channels. The update usually takes approximately 2 minutes.

2. Backup any file you modify.

3. If this is an upgrade, remove the previous installation completely before proceeding with installation of this code.

4. We recommend using the following comments to mark the code you change. This will allow you to know what was changed and why when examining the code at a later date. It also makes searching for this code change easier -- you can use the search function to search for CRE_SEO:

 //CRE_SEO Install Begin
 //CRE_SEO Install End


5. Copy .htaccess and seo.php to the root directory (or your working directory).  Choose the correct option for your installation.  If you already have a .htaccess file, simply add the following to the bottom of your .htaccess file:

*************************************************************************************
If you are running CRE loaded in your ROOT directory (yourdomain.com/), your .htaccss file will look like this:
*************************************************************************************

#CRE_SEO Begin
Options +FollowSymLinks
RewriteEngine on
RewriteBase /

#cre SEO check for images and skip all the other rules for performance reasons only
RewriteRule ^.*.gif|.jpg|.png|.css|.php$ - [L]

# cre SEO reformats for product_info.html pages
RewriteRule ^m([0-9]+_?[0-9]*)/?(.*)/p([0-9]+_?[0-9]*)/(.*)/product_info.html$ product_info.php?manufacturers_id=$1&products_id=$3 [QSA,L]
RewriteRule ^p([0-9]+_?[0-9]*)/(.*)/product_info.html$ product_info.php?products_id=$1 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/p([0-9]+_?[0-9]*)/(.*)/product_info.html$ product_info.php?cPath=$2&products_id=$3 [QSA,L]

# cre SEO reformat for index.html pages
RewriteRule ^m([0-9]+_?[0-9]*)/?(.*)/p([0-9]+_?[0-9]*)/(.*)/index.html$ index.php?manufacturers_id=$1&products_id=$3 [QSA,L]
RewriteRule ^m([0-9]+_?[0-9]*)/(.*)/index.html$ index.php?manufacturers_id=$1 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/m([0-9]+_?[0-9]*)/?(.*)/p([0-9]+_?[0-9]*)/(.*)/index.html$ index.php?cPath=$2&products_id=$5 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/p([0-9]+_?[0-9]*)/(.*)/index.html$ index.php?cPath=$2&products_id=$3 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/index.html$ index.php?cPath=$2 [QSA,L]

# cre SEO reformat for information.html pages
RewriteRule ^i([0-9]+_?[0-9]*)/(.*)/information.html$ information.php?info_id=$1 [QSA,L]

# cre SEO reformat for pages.html pages
RewriteRule ^p([0-9]+_?[0-9]*)/(.*)/pages.html$ pages.php?pID=$1 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/p([0-9]+_?[0-9]*)/(.*)/pages.html$ pages.php?cID=$2&pID=$3 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/pages.html$ pages.php?cID=$2 [QSA,L]
RewriteRule ^(.*)/CDpath([^/]*)/p([0-9]+_?[0-9]*)/(.*)/pages.html$ pages.php?CDpath=$2&pID=$3 [QSA,L]
RewriteRule ^(.*)/CDpath([^/]*)/pages.html$ pages.php?CDpath=$2 [QSA,L]

# cre SEO reformat for articles.html pages
RewriteRule ^(.*)/t([^/]*)/a([0-9]+_?[0-9]*)/(.*)/articles.html$ articles.php?tPath=$2&articles_id=$3 [QSA,L]
RewriteRule ^(.*)/t([^/]*)/articles.html$ articles.php?tPath=$2 [QSA,L]

# cre SEO reformat for article_info.html pages
RewriteRule ^a([0-9]+_?[0-9]*)/(.*)/article_info.html$ article_info.php?articles_id=$1 [QSA,L]
RewriteRule ^(.*)/t([^/]*)/article_info.html$ article_info.php?tPath=$2 [QSA,L]

# cre SEO reformats for product_reviews.html pages
RewriteRule ^p([0-9]+_?[0-9]*)/(.*)/product_reviews.html$ product_reviews.php?products_id=$1 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/p([0-9]+_?[0-9]*)/(.*)/product_reviews.html$ product_reviews.php?products_id=$3 [QSA,L]

# cre SEO reformats for product_reviews_info.html pages
RewriteRule ^p([0-9]+_?[0-9]*)/(.*)/review([0-9]+_?[0-9]*)/product_reviews_info.html$ product_reviews_info.php?products_id=$1&reviews_id=$3 [QSA,L]

# cre SEO reformat for FDMS pages
RewriteRule ^f([0-9]+)/(.*)/fdm_file_detail.html$ fdm_file_detail.php?file_id=$1 [QSA,L]
RewriteRule ^(.*)/fPath([^/]*)/fdm_folder_files.html$ fdm_folder_files.php?fPath=$2 [QSA,L]

# cre SEO reformat for FSS pages
RewriteRule ^(.*)/fPath([0-9]+)/form([0-9]+)/(.*)/fss_forms_detail.html$ fss_forms_detail.php?fPath=$2&forms_id=$3 [QSA,L]
RewriteRule ^(.*)/fPath([0-9]+)/fss_forms_index.html$ fss_forms_index.php?fPath=$2 [QSA,L]

#cre SEO catch all in case other rules did not match
RewriteRule ^(product_info|index|information|pages|articles|article_info|product_reviews|product_reviews_info).html$ $1.php [QSA,L]

#CRE_SEO Install End


6. If you are running CRE Loaded in a sub-directory (for example, yourdomain.com/catalog/), change the RewriteBase in the file above (line 4) to reflect your working directory.


Example:

RewriteBase /catalog/


7. Add the following statements to the .htaccess file in your admin section:

## admin htaccess file mod begin :

#CRE_SEO Install Begin
RewriteEngine off
#CRE_SEO Install End

## admin htaccess file mod begin :

NOTE:  If you have problems accessing Admin after adding this (e.g., you receive an Internal Server Error), remove this statement from .htaccess file and retry Admin access.  Some server configurations do not require this and will cause an error.

NOTE: Since no admin files are rewritten, this is a performance setting to prevent the list of rewrite rules from being processed for each page in the admin.

8. For CRE Loaded stores earlier than 6.2.12, the lines below must be added to the /includes/application_top.php file. As of CRE Loaded version 6.2.12, this step is no longer needed; the code ships with the lines already in place.  

Find (around Line #108):

// some code to solve compatibility issues
require(DIR_WS_FUNCTIONS . 'compatibility.php');

and insert below that:  

  //CRE_SEO Install Begin
if (file_exists(DIR_FS_CATALOG . 'seo.php') && (CRE_SEO == 'true')) {
require_once('seo.php');
}
//CRE_SEO Install End


9. For CRE Loaded stores earlier 6.2.12, the lines below must be added to /includes/application_bottom.php. As of CRE Loaded version 6.2.12, this step is no longer needed; the code ships with the lines already in place.

Go to the end of the file and insert just before the closing ?> symbol (but after any other code): 

  //CRE_SEO Install Begin
if (file_exists(DIR_FS_CATALOG . 'seo.php') && (CRE_SEO == 'true')) {
ob_end_flush();
}
//CRE_SEO Install End


10. Run the following SQL statements in the database:

INSERT INTO `configuration` ( `configuration_id` , `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `last_modified` , `date_added` , `use_function` , `set_function` )
VALUES ('', 'Use CRE SEO', 'CRE_SEO', 'false', 'Use CRE SEO (Search Engine Optimization) Urls?', '1', '12', '', '2005-08-10 14:26:54', NULL , 'tep_cfg_select_option(array(''true'', ''false''),' );

INSERT INTO configuration ( configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function )
VALUES ('', 'CRE SEO Space Replacement', 'CRE_SEO_SPACE_REPLACEMENT', '-', 'You may choose what character to replace a space in a name with.', 1, 13, '', '2005-08-10 14:26:54', NULL, 'tep_cfg_select_option(array('-', '+', '_', '%20'),' );

Upgrading from version 4.0

There are two simple steps to upgrading to 4.1 if you already have 4.0 installed:

1. Overwrite the exiting seo.php file with the new one.


2. Add the new lines shown below to the .htaccess file. These can be added so it looks like the listing on the installation page, or they can be added near the end of the file, but before the catch-all entry there.

RewriteRule ^(.*)/c([^/]*)/m([0-9]+_?[0-9]*)/?(.*)/p([0-9]+_?[0-9]*)/(.*)/index.html$ index.php?cPath=$2&products_id=$5 [QSA,L]

RewriteRule ^(.*)/CDpath([^/]*)/p([0-9]+_?[0-9]*)/(.*)/pages.html$ pages.php?CDpath=$2&pID=$3 [QSA,L]
RewriteRule ^(.*)/CDpath([^/]*)/pages.html$ pages.php?CDpath=$2 [QSA,L]

# cre SEO reformat for FDMS pages
RewriteRule ^f([0-9]+)/(.*)/fdm_file_detail.html$ fdm_file_detail.php?file_id=$1 [QSA,L]
RewriteRule ^(.*)/fPath([^/]*)/fdm_folder_files.html$ fdm_folder_files.php?fPath=$2 [QSA,L]

# cre SEO reformat for FSS pages
RewriteRule ^(.*)/fPath([0-9]+)/form([0-9]+)/(.*)/fss_forms_detail.html$ fss_forms_detail.php?fPath=$2&forms_id=$3 [QSA,L]
RewriteRule ^(.*)/fPath([0-9]+)/fss_forms_index.html$ fss_forms_index.php?fPath=$2 [QSA,L]

Getting Started

In your store's Admin => Configuration => My Store menu, set the "Use CRE SEO" and the "CRE SEO Space Replacement" options (installed in Step 10) as desired. Check the URLs with your web browser and adjust them until you are satisfied with the URL output. Do not activate osCommerce Search Engine Friendly URLs while this package is in use -- the cart will still work, but all URL adjustments will be handled by the osCommerce code rather than by CRE SEO URLs.

Troubleshooting

1.  The install is not working
Be sure that your hosting provider allows mod_rewrite directives in .htaccess. This is the biggest thing that goes wrong with the installation. If you install everything and then get a 500 error, chances are you do not have the mod_rewrite enabled on your server. Please check this before posting or reporting the issue.

REMEMBER:  If you are running CRE Loaded in a sub-directory, you will need to update .htaccess Rewrite Base so it reflects your working directory, e.g., RewriteBase /catalog/.

2. You cannot access Admin
If you have problems accessing your Admin after completing Step 7 of the installation procedures (e.g., you receive an Internal Server Error), remove the statement from .htaccess file and retry Admin access.  Some server configurations do not require this statement and will cause an error.

3. Other problems
Turn off CRE URLs in Admin => Configuration and delete the seo.php file from the catalog root directory.

Go to CRE SEO URLs Bug Tracker and post your problem. Be sure to let us know your domain name; what version of CRE Loaded you are running, including update patches; and which release of CRE SEO URLs you are attempting to install.

Known Problems and Workarounds

* Admin URLs must be protected from mod_rewrite distortion on some Apache configurations
          o WORKAROUND: Pay attention to instructions and follow them carefully
* This product is NOT for use on servers other than Apache.  This includes IIS.
* Your hosting provider must allow mod_rewrite directives in .htaccess for this software to work.
* This product can be confused by installation of html files sharing a base name with CRE Loaded PHP files.  Example: product_info.html
* This code becomes ineffective when osCommerce SEF URLs are activated.
          o WORKAROUND: Be sure osCommerce Search Engine Friendly URLs is deactivated.
* The instructions apply only to unmodified code for CRE Loaded 6.15 and CRE Loaded 6.2.x.  If you have modified your store, we recommend that you hire a professional programmer to install this product for you. Installation on customized carts is not included in the price of this product.

Uninstalling CRE SEO URLs

You must back out each step followed above, and restore your admin and catalog .htaccess files to the preinstall state.