Gato’s URL Rewrite Patch for ZenCart

The latest patch is version 1.1.3.

This page has described ZenCart ver.1.2 - ver.1.2.7.
Apache and mod_rewrite are required.
mod_rewrite may not work on some rental servers.


.htaccess

Target file: ZENCART_ROOT/.htaccess

#The following are necessary only in patch ver.0.9 and Ver.1.*.
RewriteRule ^categories/Hardware.html /index.php?main_page=index&cPath=1 [L]
RewriteRule ^categories/Graphics_Cards.html /index.php?main_page=index&cPath=1_4 [L]
RewriteRule ^categories/Keyboards.html /index.php?main_page=index&cPath=1_8 [L]
RewriteRule ^categories/Mice.html /index.php?main_page=index&cPath=1_9 [L]
RewriteRule ^products/Matrox_G200_MMS.html /index.php?main_page=product_info&products_id=1 [L]
RewriteRule ^products/Microsoft_Internet_Keyboard_PS2.html /index.php?main_page=product_info&products_id=25 [L]
RewriteRule ^products/Microsoft_IntelliMouse_Explorer.html /index.php?main_page=product_info&products_id=26 [L]

If you put zencart on sub directory, change .htaccess as follows.
Exp: http://www.your_shop.com/shop/

Before:

RewriteRule ^******.html /index.php?main_page=****** [L]

After:

RewriteRule ^******.html /shop/index.php?main_page=****** [L]

configure.php

Add one line to ZENCART_ROOT/includes/configure.php.

Target file: ZENCART_ROOT/includes/configure.php

define('USE_PCONNECT', 'true'); // use persistent connections? or false
define('STORE_SESSIONS', 'db'); // leave empty '' for default handler or set to 'db'
define('USER_FRIENDLY_URLS_REWRITE', 'true');


Main patched file

Target file: ZENCART_ROOT/includes/functions/html_output.php

Some bugs are fixed.


Many codes were completely changed.

Ver.1.0 is a missing number.


Language sidebox came to work correctly.



URL of categories and products names added to url_replace.dat and .htaccess are rewritten.

Exp: (ver.0.9)
http://example.org/categories/Hardware.html
http://example.org/products/Microsoft_IntelliMouse_Explorer.html

Exp:

http://example.com/categories/2.html   (Category URL)
http://example.com/products/27.html   (Product URL)


New addition

The new file is necessary from patch ver.0.9.
Target file: ZENCART_ROOT/url_data.php (url_replace.dat)

The name was changed from url_replace.dat to url_data.php.
Please change the name after download.
url_data_php.txt --> url_data.php

  • Download .... url_replace.dat for zencart 1.2.6 patch ver.0.9 .... Sep 30, 2005

The following change is necessary from patch ver.0.8 for zencart v1.2.6.

Target file: ZENCART_ROOT/includes/templates/YOUR_TEMPLATE/common/tpl_header.php
Find and edit following line.

from:
<a href="<?php echo zen_href_link(FILENAME_DEFAULT, '', 'NONSSL'); ?>"><?php echo HEADER_TITLE_CATALOG; ?></a>

to
<a href="/"><?php echo HEADER_TITLE_CATALOG; ?></a>

or
<a href="/index.html"><?php echo HEADER_TITLE_CATALOG; ?></a>

If you installed your zencart in sub directory, change <a href="/"> to <a href="/sub_directory/">
or
<a href="/index.html"> to <a href="/sub_directory/index.html">


Other patched files

Target file: ZENCART_ROOT/includes/modules/listing_display_order.php

echo zen_draw_form('sorter', zen_href_link(basename(ereg_replace('([a-z_]{1,}).php','index.php', $PHP_SELF)), '', $request_type, false), 'get');

This change is necessary in all versions of my url rewrite patch.


The "drops down menu form" causes some problems.
Normal currencies sidebox does not work on USER_FRIENDLY_URLS_REWRITE mode.
Copy ZENCART_ROOT/includes/templates/template_default/sideboxes/tpl_currencies.php to ZENCART_ROOT/includes/templates/YOUR_TEMPLATE/sideboxes/.
Do not edit original files in template_default directory.

ZENCART_ROOT/includes/templates/YOUR_TEMPLATE/sideboxes/tpl_currencies.php

$content .= zen_draw_form('currencies', zen_href_link(basename(ereg_replace('([a-z_]{1,}).php','index.php', $PHP_SELF)), '', $request_type, false), 'get');


Normal manufacturer's sorting in categories listing does not work on USER_FRIENDLY_URLS_REWRITE mode.
Copy ZENCART_ROOT/includes/templates/template_default/templates/tpl_index_product_list.php to ZENCART_ROOT/includes/templates/YOUR_TEMPLATE/templates/.

Do not edit original files in template_default directory. ZENCART_ROOT/includes/templates/YOUR_TEMPLATE/templates/tpl_index_product_list.php

$form = zen_draw_form('filter', zen_href_link(basename(ereg_replace('( [a-z_]{1,}).php','index.php', $PHP_SELF)), '', $request_type, false), 'get') . TEXT_SHOW;

    Download .... tpl_index_product_list_php.txt for zencart 1.2.6 ....This file need not be changed any longer.

  • Download .... tpl_index_product_list.php for zencart 1.2.1 - 1.2.5. ....Sep 19, 2004


If you are making manufacturers list sidebox effective, manufacturers should also change.
Copy ZENCART_ROOT/includes/templates/template_default/sideboxes/tpl_manufacturers_select.php to ZENCART_ROOT/includes/templates/YOUR_TEMPLATE/sideboxes/.

Do not edit original files in template_default directory.

  • Download .... tpl_manufacturers_select.php for zencart 1.2.6 ....This file need not be changed any longer.

  • Download .... tpl_manufacturers_select.php for zencart 1.2.1-1.2.5. ....Mar 10, 2005


If you want to rewrite URL of product picture links, Please edit zencart-root/includes/modules/pages/product_info/main_template_vars_images.php.
Since I did not want pop-up product pictures, I deleted "a href" tag from it.

Tkank you.