How to get Cubecart 4 friendly URLs on a Windows server

Cubecart 4 includes the option to rewrite the standard URL structure into “search engine friendly” URLs.

This means that instead of a product in your shop having the pretty awful address of

http://www.domain.co.uk/index.php?_a=viewProd&productId=1

you can have it rewritten into something like

http://www.domain.co.uk/test-category/test-product2/prod_1.html

Much easier for humans I’m sure you’ll agree and hopefully search engines will love your keyword-packed URLs too.

Activating theĀ  search engine friendly URL’s is nice and easy if you have Unix/Linux hosting as it all works out of the box with Cubecart, but if (like me) you’re using a Windows server you need a different solution… and Helicon’s ISAPI_Rewrite is just that solution.

Installed onto your Windows server (if you’re on shared hosting, speak to your hosts about making it available), ISAPI_Rewrite uses a single file (httpd.ini) in the root folder of your domain to process whatever rewriting rule you need.

Within the Cubecart admin system, you are given a few lines of code to paste into your (Unix/Linux) .htaccess file:

## Activate the mod_rewrite Engine
RewriteEngine On
RewriteCond %{QUERY_STRING} (.*)$
RewriteRule cat_([0-9]+)(\.[a-z]{3,4})?(.*)$ index.php?_a=viewCat&catId=$1&%1 [NC]
RewriteCond %{QUERY_STRING} (.*)$
RewriteRule prod_([0-9]+)(\.[a-z]{3,4})?$ index.php?_a=viewProd&productId=$1&%1 [NC]
RewriteCond %{QUERY_STRING} (.*)$
RewriteRule info_([0-9]+)(\.[a-z]{3,4})?$ index.php?_a=viewDoc&docId=$1&%1 [NC]
RewriteCond %{QUERY_STRING} (.*)$
RewriteRule tell_([0-9]+)(\.[a-z]{3,4})?$ index.php?_a=tellafriend&productId=$1&%1 [NC]
RewriteCond %{QUERY_STRING} (.*)$
RewriteRule _saleItems(\.[a-z]+)?(\?.*)?$

Unfortunately, I couldn’t get these to translate directly into my httpd.ini file, but I found this solution on the Helicon forums:


[ISAPI_Rewrite]
RewriteRule .*?/cat_(\d+)(?:\.[a-z]{3,4})?([^?]*)(?:\?(.*))? /index.php\?_a=viewCat&catId=$1?2&$2 [I,L]
RewriteRule .*?/prod_(\d+)(?:\.[a-z]{3,4})?(?:\?(.*))? /index.php\?_a=viewProd&productId=$1?2&$2 [I,L]
RewriteRule .*?/info_(\d+)(?:\.[a-z]{3,4})?(?:\?(.*))? /index.php\?_a=viewDoc&docId=$1?2&$2 [I,L]
RewriteRule .*?/tell_(\d+)(?:\.[a-z]{3,4})?(?:\?(.*))? /index.php\?_a=tellafriend&productId=$1?2&$2 [I,L]
RewriteRule .*?/_saleItems(?:\.[a-z]+)?(\?(.*))? /index.php\?_a=viewCat&catId=saleItems?1&$1 [I,L]

Just put the code above into your httpd.ini file, upload it and the changes should take effect immediately with no server reboot required.

Happy Cubecarting!

3 Responses to How to get Cubecart 4 friendly URLs on a Windows server
  1. Steve R

    Seems to be focusing the mind this cube cart thing….

  2. name

    Hello!,

  3. Mo

    Any idea how to make it work on a litespeed server?

Leave a Reply

Your email address will not be published. Please enter your name, email and a comment.

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>