Every time that I have to move a PrestaShop site, developing or supporting XT Search for Algolia, I face the same dilemma. I follow the steps recommended in the official Best Development Practices: How can I migrate my PrestaShop store to a new server? Still, after downloading the backup, restoring the files, restoring the database and configuring app/config/parameters.php I got redirected to the original domain!
The problem is simple, you restore the site, you test the new site and ...
~$ curl -I https://demo-prestashop.localhost/ HTTP/1.1 301 Moved Permanently Date: Wed, 01 Apr 2020 16:58:07 GMT Server: Apache/2.4.29 (Ubuntu) Strict-Transport-Security: max-age=31536000; includeSubDomains Location: https://demo-prestashop.extly.com/ Content-Type: text/html; charset=iso-8859-1
The solution: replace the domain that is repeated four times in the database tables! ... and, of course, the domain is also in the .htaccess.
- Table `dbprefix_configuration`, records PS_SHOP_DOMAIN and PS_SHOP_DOMAIN_SSL
- Table `dbprefix_shop_url`, fields `domain` and `domain_ssl`
UPDATE `dbprefix_configuration` SET `value` = "demo-prestashop.localhost" WHERE `value` = "the-original-domain.com"; UPDATE `dbprefix_configuration` SET `value` = "http://demo-prestashop.localhost" WHERE `value` = "http://the-original-domain.com"; UPDATE `dbprefix_configuration` SET `value` = "https://demo-prestashop.localhost" WHERE `value` = "https://the-original-domain.com"; UPDATE `dbprefix_shop_url` SET `domain` = "demo-prestashop.localhost", `domain_ssl` = "demo-prestashop.localhost" WHERE `domain` = "the-original-domain.com";
- Change app/config/parameters.php
- Change the .htaccess
- Run the queries to change the `dbprefix_configuration` and `dbprefix_shop_url` tables
- To be on the safe side, clear the cache folder var/cache/prod
That's it! Clear the cache and no more redirections.
curl -I https://demo-prestashop.localhost/ HTTP/2 200 date: Wed, 01 Apr 2020 17:06:32 GMT
To the moon!
Bonus Tip: Cache Configuration and Development Mode
If there is a system mismatch and a PHP extension (such as APC PECL extension), PrestaShop doesn't come up even when the points detailed above are OK. To check what's going on, you can enable the Development Mode (config/defines.inc.php, _PS_MODE_DEV_ = true) and disable the configured cache completely (app/config/parameters.php, ps_cache_enable' => false).