Top Question Answers about PrestaShop URL Redirect in 2017

URL redirect has now become an essential task for most of the merchant. They need to redirect their shops for many of the purposes;

·         When a site needs maintenance, merchants have to redirect it to other domain for short period of time

·         When a store is completely shut down and shifter to another domain

·         When merchants want to redirect from http to https server

·         When merchants have to redirect non-www to www protocol.

·         When a merchants migrate from others shopping carts to PrestaShop

By default, PrestaShop has not easy options to redirect URLs, so this task can be done by two methods

·         Editing the htaccess file to redirect

·         Use a PrestaShop redirect module

Here our topic is not related to defining the way to redirect but we will confine to some common problem and their solution related to PrestaShop redirect. So given here Top Question Answers about PrestaShop URL Redirect in 2017;

Question No. 1: I am using PrestaShop and I have multistore enabled. I have migrated my shops from other shopping carts to PrestaShop. So I want to 301 redirect all my product and categories so that Google will index my new urls keeping intact my old ranking. Is it possible through adding redirects through htaccess file or it follows some other formula?

Answer:  It can be done through php files instead of htaccess. Just create a file named “old_sit_redirect.php and paste the following code in it. Here you have to OLD url and new URL as per your own urls.


$url_redir_maps = array(

'/some_old_url.html' => '/some_new_url',

'/old_url2' => '/new_url2',

(...and so on)


if(in_array(@$_SERVER['REQUEST_URI'], array_keys($url_redir_maps))){

header("HTTP/1.1 301 Moved Permanently"); 

header("Location: ".$url_redir_maps[@$_SERVER['REQUEST_URI']]);



Question No. 2: Hi, I am using default PrestaShop module for redirect but the header that it is generating is totally wrong. The URLs is with the header https but when it redirects, it goes to http version.

Answer: Try to paste the exact url before passing it to Tools::redirect() function and then see that either it is redirecting to http or https. However, the point to be noted is that this PrestaShop function can’t do such task of changing the version from https to http. It may be problem with the redirecting url.

Question No. 3: I have migrated my store from another shopping cart to PrestaShop and I want to redirect the old ULRs to new URLs. When I redirect, old pages are not correctly redirecting to new urls. The reason of this issue is that I am not using www in start. I am not using it because If I will use it, I am unable to login to my store. Also, in this way my customers can’t login to their accounts. How can I solve this issue?

Answer: To solve this issue of www and non-www, you have to include following code at the top of your htacccess.

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www.

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Question No. 4: I have shifted my old shopping cart to PrestaShop and I want to redirect all my old urls to new one so that I can avoid the 404 error for those old pages that are indexed by Google.



old site


new site

Answer: You can do by adding these lines in the htaccess file. It is the method of 301 redirect.

Options +FollowSymLinks

RewriteEngine on

RewriteRule (.*)$1 [R=301,L]

Question No. 5: I am trying to redirect my urls in PrestaShop 1.5.4. I tried different methods of redirection through htaccess file by adding code after, before and inside but nothing solved the issue. As the old URLs are not redirecting to new urls correctly.

Answer: You have to place the following code at the top of index.php file.

if (strpos($_SERVER['REQUEST_URI'], OLD_URL_GOES_HERE) !== false) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: OLD_URL_GOES_HERE");

Note: These questions are answered by top community developers and do not reflect “FMEModules”