Glossary Item Box
Overview
Squirrelcart allows you to control the format of your URLs that link to products, categories, and other pages. We will refer to this feature with the term SEO URLs, (SEO stands for Search Engine Optimized). Here are 4 examples of product page URLs based on how you have your SEO URL settings configured:
Query String URL: (OK)
http://www.example.com/store.php?crn=180&rn=279&action=show_detail
This method has data in the URL that helps Squirrelcart determine what to show your customer. That data is only meaningful to your web server.
Search Engine Optimized URL: (better!)
http://www.example.com/store.php/products/deluxe-bookshelf/
This method removes the query string data and replaces it with more meaningful information. If this page was indexed in a search engine, searching for "deluxe bookshelf" is more likely to generate a result linking to this page.
Search Engine Optimized URL - Advanced: (much better!)
http://www.example.com/products/deluxe-bookshelf/
This method is identical to the previous one with the exception that the storefront page is no longer present (store.php by default).
Search Engine Optimized URL - Advanced: (best!)
http://www.example.com/furniture/deluxe-bookshelf/
This method is identical to the previous one with the exception that the category, product, and content bases are not used. When viewing a product, it is preceded by a base matching it's category for better SEO. Category and content URLs are not prefixed with any base, and the storefront page is no longer present (store.php by default).
For this setup, enable SEO URLs, then follow the steps under SEO URLs (Advanced) below, and be sure to check the Smart Bases checkbox.
Query String URLs
Requirements:
None
Setup Instructions:
We recommend using SEO URLs when possible. If your server doesn't support them, here's how to configure Squirrelcart to use query string URLs.
SEO URLs
Requirements:
Your server must support the $_SERVER['PATH_INFO'] variable OR support both the $_SERVER['SCRIPT_NAME'] and $_SERVER['REQUEST_URI'] variables.
Precautions:
![]() |
When enabling SEO URLs, you are changing the URL structure for Squirrelcart content. Because of this, any code you've written yourself in your storefront must use absolute URLs. If you are using relative URLs in your Squirrelcart storefront, those URLs will not be valid. This will result in broken links, broken images, etc... See the Broken Images and Links section at the end of this page for more information. |
Overview
Enabling SEO URLs will turn your URLs from something like this:
http://www.example.com/store.php?crn=180&rn=279&action=show_detail
To this:
http://www.example.com/store.php/products/deluxe-bookshelf/
Setup Instructions:
http://www.example.com/store.php/categories/books
http://www.example.com/store.php/products/coffee-table
http://www.example.com/store.php/news/2008/11/25/post-name
http://www.example.com/store.php/news/archives
http://www.example.com/store.php/reviews/product-name
http://www.example.com/store.php/reviews/reviewer-382
http://www.example.com/store.php/testimonials
http://www.example.com/store.php/contact
http://www.example.com/store.php/downloads
http://www.example.com/store.php/store-locator
http://www.example.com/store.php/content/about-us
http://www.example.com/store.php/categories/books/page-4
http://www.example.com/books
http://www.example.com/books/gone-with-the-wind
http://www.example.com/gone-with-the-wind
http://www.example.com/about-us
![]() |
With Smart Bases enabled, if you also enable No Filename, you must use Method 1 in the SEO URLs (Advanced) steps towards the bottom of this page. |
http://www.example.com/store.php/products/this-is-a-long-product-name
http://www.example.com/store.php/products/this_is_a_long_product_name
![]() |
Do not check this field without following the instructions in the Setting up SEO URLs (advanced) section below! |
Customizing
You can control how product, category, and news post names appear in your URLs by modifying the SEO URL Name field in each respective table in your control panel. Here's an example of this field on a category record.
Redirects
If a user tries to load a page using a query string URL after you have enabled SEO URLs, Squirrelcart will issue a redirect (HTTP code 301) to the equivalent SEO URL. This will ensure search engines know the page has moved to a different location, and help to avoid penalties for duplicate content.
If you decide to change the SEO URL Name field for a particular item (see Customizing section directly above), and a URL is requested using the prior value you had stored in that field, Squirrelcart will issue a redirect to the new URL.
Example: Using the image above, the URL to the "Compact Discs" category is:
http://www.example.com/store.php/categories/compact-discs
Now, 3 months after that page has been indexed by a search engine you decide to change your URL to this by changing the SEO URL Name field to cds:
http://www.example.com/store.php/categories/cds
If the old URL is requested by a user, they will automatically be redirected to the new URL.
SEO URLs (advanced)
Overview
This is an additional procedure you can follow to remove the storefront page from your URLs after you've followed the steps above to enable SEO URLs. This is an advanced topic, and caution should be taken when attempting this procedure.
This will change your URLs from something like this:
http://www.example.com/store.php/products/coffee-table
To this:
http://www.example.com/products/coffee-table
With the Smart Bases feature enabled, you can get even nicer URLs that don't use the category, product, and content bases:
http://www.example.com/furniture
http://www.example.com/furniture/coffee-table
http://www.example.com/about-us
Requirements
Setup Instructions Explained
There are 3 ways to handle this. All require .htaccess file support. The first two methods uses mod_rewrite, and the second uses either ForceType or SetHandler directives. Follow the section below that corresponds to what your server has support for. If you aren't sure, we recommend you follow the mod_rewrite instructions first. If they do not work, then try the "ForceType/SetHandler" instructions.
Method 1 (recommended): Setup Instructions Using Mod_Rewrite, Giving Squirrelcart Full Control
Mod_Rewrite is a feature built into Apache web servers that allows you to transform the URL requested by a client into a different URL without the client seeing their URL change in their browser. With this method, when the customer requests a URL like:
http://www.example.com/products/coffee-table
Mod_Rewrite will change their request to include your storefront page without changing the URL in their browser:
http://www.example.com/store.php/products/coffee-table
This method will send all page requests for any folder or file that does not actually exist on your server to Squirrelcart, in turn giving Squirrelcart full access to just about any URL. If you want to use the Smart Bases feature (highly recommended), you will need to use this method.
RewriteEngine On
# This tells the rule to NOT redirect to index.php if request is for a directory that exists
RewriteCond %{REQUEST_FILENAME} !-d
# This tells the rule to NOT redirect to index.php if request is for a file that exists
RewriteCond %{REQUEST_FILENAME} !-f
# This tells the rule to NOT redirect if the request had an extension other than .php
RewriteCond %{REQUEST_URI} \.php|/[^\.]*$ [NC]
# All other requests redirected to index.php
RewriteRule ^(.*)$ store.php/$1 [L]
http://www.example.com/products/
Method 2: Setup Instructions Using Mod_Rewrite, Giving Squirrelcart Partial Control
Mod_Rewrite is a feature built into Apache web servers that allows you to transform the URL requested by a client into a different URL without the client seeing their URL change in their browser. With this method, when the customer requests a URL like:
http://www.example.com/products/coffee-table
Mod_Rewrite will change their request to include your storefront page without changing the URL in their browser:
http://www.example.com/store.php/products/coffee-table
If you want to use the Smart Bases feature (highly recommended), you cannot to use this method. See method 1 above.
RewriteEngine On
RewriteRule ^(products|categories|content|news|reviews|testimonials|contact|downloads|store-locator|auth)/?(.*)$ store.php/$1/$2 [L]
http://www.example.com/products/
Method 3: Setup Instructions Using ForceType/SetHandler
ForceType is a directive you can use in an htaccess file to force a file to be treated as a particular MIME type regardless of it's file extension. This method works by tricking your server into serving files named "products" and "categories" (with no file extension) into opening as PHP files. These file names will look just like directory names in your URLs, and your customers won't know that they are actually PHP pages.
<Files ~ "categories|products|news|reviews|testimonials|contact|downloads|store-locator|auth">
ForceType application/x-httpd-php
</Files>
<?php
// prefix path info with the name of this file, which should equal the URL Base for whatever purpose this file servers
$_SERVER['PATH_INFO'] = '/'.basename(__FILE__).$_SERVER['PATH_INFO'];
// include storefront page
include 'store.php';
?>
http://www.example.com/products/
Broken Images and Links
On a default installation of Squirrelcart, the SEO URL feature will work fine. If you have customized your storefront page or product/category descriptions to include image tags or links, those images and links may break. This explains why, and how to resolve it.Absolute and Relative URLs
An absolute URL includes your domain name, as in the src attribute of the IMG tag below.
Example 1: absolute URL
A relative URL is relative to the page that you are currently on in your browser.
Example 2: relative URL
The image tag in example 1 would work on any page that contains that code, regardless of the location of the file (even on a different website). This is because it contains the full location pointing to the image file.
The image tag in example 2 will only work when it appears on a web page that is in a folder containing a folder named images.
How this applies to Squirrelcart's SEO URL feature
If you have the code shown in example 2 above on your storefront page (store.php in this example), and are using query string URLs in Squirrelcart, loading this example category URL would result in the image my_logo.gif loading without a problem:
http://www.example.com/store.php?crn=123
If you enable SEO URLs, your category (and other) URLs will change to something like this:
http://www.example.com/store.php/categories/mystery-novels
If you load that URL in a browser, the image tag shown in example 2 that used to work will now result in a broken image. This is because your browser is looking for the image relative to the current location. It is basically looking for the image here:
http://www.example.com/store.php/categories/mystery-novels/images/my_logo.gif
How to resolve this
There are 2 ways to resolve this.
Option 1 - Change relative URLs to absolute URLs using Squirrelcart's root variables (recommended)
When the code appears on a PHP page with Squirrelcart's code on it, it's best to use Squirrelcart's built in constants to insert the root URL for your store or image directory into your code. For example, this constant will be set to the regular "http" URL of your image folder when you are on a regular page, and your secure root URL to the same folder when you are on a secure page.
Example 3: Absolute URL using Squirrelcart's SC_IMG_DIR_DYN constant
You can find a list of our constants at the bottom of this page.
Option 2 - Change relative URLs to be relative to the top level directory
When a relative URL starts with a forward slash, it tells your browser to start looking for that file in the top level directory. Changing your URLs like this will keep them working with the SEO URL feature enabled.
Example 4: relative to root of site
Canonical Links
Pages may have a few different URLs that may point to the same page, for filtering results, sorting, changing page numbers, tracking affiliate links, etc...
This may cause search engines to treat those page variants as duplicate content. To prevent this, Squirrelcart automatically sets a canonical <link/> tag on these pages, pointing to the correct master URL for these variant URLs.
For example, if you are tracking add clicks to a product page via a custom parameter like adclick, you may want to send a customer to a product page like this so you can track the ad click via your web statistics software:
http://www.example.com/books/?adclick749af82734
If this page is indexed by a search engine, it looks just like the version without the adclick parameter and looks like duplicate content. For the above example, Squirrelcart will automatically add this link to prevent that from happening:
<link rel="canonical" href="http://www.example.com/books" />
Pagination
When viewing a category or when viewing search results, if more products are available than will fit on a page, that page may contain page navigation links to navigate to other pages in the data set.
Search engines may see these pages as duplicate content. To help search engines understand pagination, Squirrelcart implements one of two different features, depending on your settings:
Prev and Next Links
When there are more pages in a dataset than the number specified in the above setting, all paginated result pages automatically get a <link/> tag added to their <head/> tags, to explain the pagination, using the rel="prev" and rel="next" attributes. For example, on page 2 of a category containing 3 or more pages, these tags will be added to the <head/> tag:
<link rel="prev" href="http://www.example.com/books/page-1/" />
<link rel="next" href="http://www.example.com/books/page-3/" />
Linking to Products and Categories
We've added some functions to make it easier to link to products and categories in custom PHP code. If you need to do this, we recommend using these functions, as they will use the appropriate URL format based on your settings, and will automatically be updated should you change the SEO URL Name field on your records. Just plug in your product or category record number.
Linking to a Product Page
<a href="<?php print get_product_url(854) ?>">checkout this product</a>
Linking to a Category Page
<a href="<?php print get_category_url(64) ?>">checkout this category</a>
© 2001-2017 Lighthouse Development. All Rights Reserved.