Posts

PrestaShop

How to move a PrestaShop 1.6 from one domain to another (resolving redirect problems)

There are several descriptions online on how to do this but in one occasion, even though I followed the instructions carefully it kept redirecting me to the old domain name. In my particular case the culprit was that the site used file system cache which was active before the move.

The following procedure fixed my problem. The base of the instructions come from the PrestaShop site with my additions below.

  1. Put the site in Maintenance mode.
  2. Copy all files from the old site (domain) to the new using for example a FTP program.
  3. Dump the old site database to a file and import the database on the new server.
  4. Edit config/settings.inc.php and update the values for _DB_SERVER, _DB_NAME, _DB_USER, _DB_PASSWD and you might need to adjust _PS_DIRECTORY value.
  5. Using phpMyAdmin, go to the table ps_store_url and update the record regarding domain name and physical uri.
  6. Using phpMyAdmin, go to the table ps_configuration and find the records for column name with the records for PS_SHOP_DOMAIN, PS_SHOP_DOMAIN_SSL and __PS_BASE_URI__ and update the values corresponding to the new domain name and base uri.
  7. Using FTP (or other preferred method) clear all content except index.php of the ‘/cache/smarty/compile’ and ‘/cache/smarty/cache’ directories.
  8. Using FTP (or other preferred method) clear all content of the ‘/cache/cachefs’ directory.
  9. Log in to the backend and disable Maintenance mode.

Remove or add www to URL using Apache mod_rewrite

To avoid a website being considered as "duplicate content" by Google (i.e. the same website appearing under different URLs) it is a good idea to make sure the website doesnt appear as both http://www.example.com and http://example.com. This can be achieved by using the mod_rewrite in Apache using the .htaccess file.

To remove "www" from the URL, i.e. the website’s URL should be http://example.com, your .htaccess should look like this: 

RewriteEngine On
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

If you instead want to make sure "www" is added, i.e. the website’s URL should be http://www.example.com, your .htaccess should look like this: 

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]