using .htaccess mod_rewrite to convert incoming url request.

Hi, I’m switching to CS-Cart from another e-commerce program. When I make the switch I would like to convert url web page request to the new cs-cart url.

Lucky for me they are pretty close.

My old cart displays the product url like this [url][/url]

The CS-Cart URL looks like this


All I need to do is to strip the -p-529 which is the actual product number from the url.

Is there a way using mod_rewrite to strip -p- and the product number from the url so the correct page comes up?

Thanks in Advance,


Your product SEO name will be automatically created from the “Product name” that you enter. It may take some time depending on how many products you upload at one time but as long as the product is “Available”, the SEO name will be created.

Hi, Yes I understand that. I don’t think you understood my question. Let me re ask it another way.

I ran OSCommerce with Ultimate SEO’s. It adds -p-429.html to each SEO name. Since I used the same product names with CS-Cart the CS-Cart’s SEO url is in the same format as what my OSCommece site used because the products are named the same on both sites other then CS-Cart doesnt use the -p-429.html on it.

I have TONS of urls out there on various websites sites that I still want to work so people don’t get a page not found message.

So all I need is for .htaccess to take any inbound URL request and to strip -p-429 from the URL and send it to CS-Cart.

I see what you are saying and that is way over my head. I don’t think it may be possible to do what you are describing.

I know that CS-Carts earlier versions had SEO in the format you are describing and when they changed the format, we basically just had to start over with the new format and be re-indexed.

You can choose to set the SEO name to whatever you like. So why not just make the CS-cart SEO name to match the old one with the -p-429 etc. That way any old links will still work.

Hi, Because I would have to edit 700+ SEO product names. Using .htaccess I should be able to create 1 or two lines with a rewritecond and rewrite rule to do the same thing by just striping out the -p-####

If anyone else needs to do this thats upgrading from OSCommerce with the Ultimate SEO contribution or a cart that does something simular, here is how its done.

In /addons/seo/init.php look for.

if ((AREA == 'C') && !empty($sef_rewrite)) {
$rewrite_rules = fn_get_rewrite_rules();
if (!preg_match('!^(.*)?/('.$customer_index.'|'.$image_index.')(.*)$!', $_SERVER['REQUEST_URI'])) {
$url_pattern = parse_url($_SERVER['REQUEST_URI']);

And add

// {{{ Strip out OSCommerce's product id from URL
$url_pattern['path'] = preg_replace('/-p-\d+\.html$/', '.html', $url_pattern['path']);
// }}}

it should end up looking like this

if ((AREA == 'C') && !empty($sef_rewrite)) {
$rewrite_rules = fn_get_rewrite_rules();
if (!preg_match('!^(.*)?/('.$customer_index.'|'.$image_index.')(.*)$!', $_SERVER['REQUEST_URI'])) {
$url_pattern = parse_url($_SERVER['REQUEST_URI']);
[COLOR="Red"] // {{{ Strip out OSCommerce's product id from URL
$url_pattern['path'] = preg_replace('/-p-\d+\.html$/', '.html', $url_pattern['path']);
// }}}[/COLOR]
foreach ($rewrite_rules as $pattern => $query) {
if (preg_match($pattern, $url_pattern['path'], $matches) || preg_match($pattern, urldecode($query), $matches)) {
$_query = preg_replace("!^.+\?!", '', $query);
parse_str($_query, $objects);

How to convert [url][/url] to [url][/url]

because google index only [url][/url]

but my site shows [url][/url]

Admin/addons/Seo edit the settings in there.


yes, I enable the Show language in the URL

I meant I just want en/xx.html to show xx.html, not fr/xx.html

in another word enable the “Show language in the URL”

and I want to my site in english with that kind of url [url][/url] and franch with url like [url][/url]