Ecommerce Templates > Search engine friendly > Search engine friendly URLs - PHP Version

Search engine friendly URLs - PHP Version

search engine friendly

It is possible to make the URL structure of the ECT generated URLs even more search engine friendly by removing any files extensions or query parameters by using URL Rewriting - (Your server must support this), leaving you with the cleanest URL possible, This should also help in your offline marketing efforts, making it much easier to show and spell out the URL of particular products and categories. This feature requires a minimum version of ECT of 6.4.

These are the steps required if you are using the PHP version of Ecommerce Templates

Open your products.php and categories.php pages and before the closing </head> tag add the following

<base href="" />

If you are using WordPress that can go in the file header.php somewhere before the closing </head> tag.

If you have your store in a different folder and not in the web root that would be something like

<base href="" />

If your site has an SSL certificate installed that would need to be

<base href="http<?php if(@$_SERVER['HTTPS']=='on') print 's'?>://" />

In vsadmin/includes.php the following parameters are available...


The parameters explained

By setting this parameter the cart will produce Product Detail Page URLs in the new SEO format...

By setting this parameter the cart will produce Category and Product Page URL's in the new SEO format...

This parameter is optional but if used will replace space characters in your product names with the character specified.

These parameters are optional but can be used to override the default category and product page formats.

This parameter is optional and shouldn't be used until you have your SEO URL system fully functional. Adding this parameter will cause an HTTP 301 Moved Permanently error to be generated (to inform Search Engines that your page has moved to a new location) and will cause the page to automatically forward to that new location.

The last step is to create a .htaccess file. It may be you already have a .htaccess file in your store root but if you don’t you can make your own by opening up your preferred text editor like Notepad and pasting in the following code

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^category/([^/.]*)/?$ /categories.php?cat=$1 [QSA,nc,L,B]
RewriteRule ^products/([^/.]*)/?$ /products.php?cat=$1 [QSA,nc,L,B]
RewriteRule ^manufacturer/?$ /categories.php?man=all [QSA,nc,L,B]
RewriteRule ^manufacturer/([^/.]*)/?$ /products.php?man=$1 [QSA,nc,L,B]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) proddetail.php?prod=$1 [QSA,nc,L,B]

Then go to Save As, choose “Save As Type > All Files” and enter .htaccess – making sure it’s not saved at a .txt file or with another file extension. Upload that file to your store root (where you have the cart.php, products.php thanks.php etc files)

If you are already using a .htacess file, add the code above and save and upload.

WordPress users

If you are using WordPress as the platform for your ECT store you can follow the steps for the PHP version above but with the following notes.
In vsadmin/includes.php the parameters will need to be formatted like this


There will already be a .htacccess file in the store root so that can be edited and make sure anything you add comes before the line

# BEGIN WordPress

In your WordPress admin under Settings > Permalinks, check which setting you have enabled there. If for example you have chosen “Numeric -”, make sure you add the following to your .htaccess file

RewriteCond %{REQUEST_URI} !/archives/

Just before the line

RewriteRule ^([^/.]+)$ proddetail.php?prod=$1 [QSA,nc,L,B]

If you are using a custom structure and not /archives/ substitute that for /archives/ in the line above.

Choose your own URL for the detail page

It is possible to not use the product name for the product detail URL and to enter the one of your choice. In the product admin page select "Has Static URL"

Static URL

and enter the text you would like to appear. In this case you would get an address of

Extensionless URLs for other store pages

From Version 6.9.2 Extensionless URL's or URL's with non-standard extenions can be created for all cart pages by specifying the parameter "extension" in your includes.php file. For extensionless URL's you can set the parameter to an empty string as follows...


You may also want to use a trailing slash for cart pages, for instance...


This would make the cart page URL

For this to work you do need to have access to a URL rewriting method as the rewritten URL needs to be mapped back to the page name with the .php extension, but it will mean that internally generated links will use the extension you specify.

For example, for the cart page an URL like this would need the following adding to .htaccess

RewriteRule ^cart/$ cart.php [NC,L]

You can do the same for other pages like clientlogin.php, search.php etc


Remember to add the following in the HEAD section somewhere before your css lines on each of the extensionless URL pages.

<base href="http<?php if(@$_SERVER['HTTPS']=='on') print 's'?>://" />


Testing the results

It's crucial that once you have the extension-less URLs set up that you fully test your store. This not only means flicking through the pages and links on your site but also looking under the hood and making sure the correct server headers are returned so search engines can find, crawl and index the new URLs.

The first thing you should do is check the HTTP status returned by the server. There are several sites that allow you to type in the URL of your pages and check the server response, for example

You would be looking at the page returning a 200 HTTP response. If you get a 404 response it would indicate a problem as your page wasn't found. In this instance you would need to go over the instructions again and if you can't find where the problem lies, please post on our support forum.

For ongoing monitoring we strongly recommend seting up a Webmaster Tools account if you don't already have one. As your site is crawled any server errors will be reported along with the referring link and date of discovery. It may take several days or weeks for new pages to be found and reported but it does allow you to keep on top of any errors over time.

Multiple Language Feature

If you are using the multiple language feature the content of the .htaccess file will be slightly different.

For example if you have your Spanish language site set up in a directory called /es/ your .htaccess file would look like this

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^es/category/([^/.]*)/?$ /es/categories.php?cat=$1 [QSA,nc,L]
RewriteRule ^es/products/([^/.]*)/?$ /es/products.php?cat=$1 [QSA,nc,L]
RewriteRule ^es/manufacturer/?$ /es/categories.php?man=all [QSA,nc,L]
RewriteRule ^es/manufacturer/([^/.]*)/?$ /es/products.php?man=$1 [QSA,nc,L]
RewriteCond $1 !\.(png|gif|jpg|ico|css|js|php)$ [NC]
RewriteRule ^es/([^/]+)$ /es/proddetail.php?prod=$1 [QSA,nc,L]

RewriteRule ^category/([^/.]*)/?$ /categories.php?cat=$1 [QSA,nc,L]
RewriteRule ^products/([^/.]*)/?$ /products.php?cat=$1 [QSA,nc,L]
RewriteRule ^manufacturer/?$ /categories.php?man=all [QSA,nc,L]
RewriteRule ^manufacturer/([^/.]*)/?$ /products.php?man=$1 [QSA,nc,L]
RewriteCond $1 !\.(png|gif|jpg|ico|css|js|php)$ [NC]
RewriteRule ^([^/]+)$ proddetail.php?prod=$1 [QSA,nc,L]

Also make sure you have the $orstoreurl set in the es/vsadmin/includes.php file.


If the css doesn't render on your new search engine friendly pages, make sure that the "base href" line comes somewhere before any css line or the "incectstyle.php" include line, eg

<base href="" />
<?php include "vsadmin/inc/incectstyle.php"; ?>
<link rel="stylesheet" type="text/css" href="/style.css" />

If you are seeing some 404 errors on particular products or categories, check that the product or category name doesn't include non-permitted characters such as a dash or period.

If you have a product or category name with the decimal point / period / dot you can replace this line in the .htaccess file

RewriteRule ^([^/.]+)$ proddetail.php?prod=$1 [QSA,nc,L,B]


RewriteCond $1 !\.(png|gif|jpg|ico|css|js|php)$ [NC]
RewriteRule ^([^/]+)$ proddetail.php?prod=$1 [QSA,nc,L,B]

Top of page

More search engine friendly features from Ecommerce Templates

Top of page