Redirects Setup

Step 4 supportive article: Learn how to configure redirects from your old X-Cart 4 store to the new X-Cart 5 one.

Olga Tereshina avatar
Written by Olga Tereshina
Updated over a week ago

After you have completed the migration and replaced the X-Cart 4 store with the new X-Cart 5 one, you need to find the following piece of code in your .htaccess file:

RewriteRule (^|/)\. - [F]

and put the next part of the code BEFORE that:

RewriteCond %{QUERY_STRING} cat=([0-9]+) 
RewriteRule ^home\.php$ cart.php?target=category&category_id=%1 [L,R=301]

RewriteCond %{QUERY_STRING} productid=([0-9]+)
RewriteRule ^product\.php$ cart.php?target=product&product_id=%1 [L,R=301]

RewriteCond %{QUERY_STRING} productid=([0-9]+)
RewriteRule ^add_review\.php$ cart.php?target=product&product_id=%1#product-details-tab-reviews [L,R=301]

RewriteCond %{QUERY_STRING} pageid=([0-9]+)
RewriteRule ^pages\.php$ cart.php?target=page&id=%1 [L,R=301]

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

RewriteRule ^register.php cart.php?target=profile [NC,L]

RewriteRule ^search.php cart.php?target=search [NC,L]

# If you have Gift Certificates module in X-Cart 5
RewriteRule ^giftcert.php cart.php?target=gift_certs [NC,L]

# If you have Shop By Brand module in X-Cart 5
<If "-f '%{REQUEST_FILENAME}.manufacturers.php' && ! %{QUERY_STRING} manufacturerid=([0-9]+)">
RewriteRule ^manufacturers\.php$ cart.php?target=brands [L,R=301] </If>
RewriteCond %{QUERY_STRING} manufacturerid=([0-9]+)
RewriteRule ^manufacturers\.php$ cart.php?target=brand&brand_id=%1 [L,R=301]

RewriteRule ^help.php cart.php?target=contact_us [NC,L]

RewriteRule ^login.php cart.php?target=login [NC,L]

This code ensures that the product, category, and static pages properly indexed in X-Cart 4 will redirect to their successors in the X-Cart 5 store.

If you use an nginx web-server instead of Apache and .htaccess rules do not work for you, here is the equivalent of the same rules in the nginx syntax:

# RewriteCond %{QUERY_STRING} productid=([0-9]+) 
# RewriteRule ^product\.php$ cart.php?target=product&product_id=%1 [L,R=301]
location = /product.php {
rewrite ^ /cart.php?target=product&product_id=$arg_productid;
}

# RewriteCond %{QUERY_STRING} productid=([0-9]+)
# RewriteRule ^add_review\.php$ cart.php?target=product&product_id=%1#product-details-tab-reviews [L,R=301]

location = /add_review.php {
rewrite ^ /cart.php?target=product&product_id=$arg_productid#product-details-tab-reviews; }

# RewriteCond %{QUERY_STRING} pageid=([0-9]+)
# RewriteRule ^pages\.php$ cart.php?target=page&id=%1 [L,R=301]
location = /pages.php {
rewrite ^ /cart.php?target=page&id=$arg_pageid;
}

# RewriteCond %{QUERY_STRING} cat=([0-9]+)
# RewriteRule ^home\.php$ cart.php?target=category&category_id=%1 [L,R=301]
location = /home.php {
rewrite ^ /cart.php?target=category&category_id=$arg_cat;
}

# RewriteRule ^register.php cart.php?target=profile [NC,L]
location = /register.php {
rewrite ^ /cart.php?target=profile;
}

# RewriteRule ^search.php cart.php?target=search [NC,L]
location = /search.php {
rewrite ^ /cart.php?target=search;
}

# If you have Gift Certificates module in X-Cart 5
# RewriteRule ^giftcert.php cart.php?target=gift_certs [NC,L]
location = /giftcert.php {
rewrite ^ /cart.php?target=gift_certs;
}

# If you have Shop By Brand module in X-Cart 5
# RewriteCond %{QUERY_STRING} manufacturerid=([0-9]+)
# RewriteRule ^manufacturers\.php$ cart.php?target=brand&brand_id=%1 [L,R=301]
location = /manufacturers.php {
if ($arg_manufacturerid){
rewrite ^ /cart.php?target=brand&brand_id=$arg_manufacturerid;
}
rewrite ^ /cart.php?target=brands;
}

# RewriteRule ^help.php cart.php?target=contact_us [NC,L]
location = /help.php {
rewrite ^ /cart.php?target=contact_us;
}

location = /login.php {
rewrite ^ /cart.php?target=login;
}

Related pages:

Did this answer your question?