Prestashop redirects to old domain after changing it in Database
Asked Answered
J

6

10

I am trying to create a copy of a prestashop 1.6 e-shop for development purposes from domain.com to dev.domain.com

The process I followed is

  1. Disable cache and compilation
  2. Copy the files from domain.com to dev.domain.com
  3. Dump the mysql database from domain.com in dump.sql
  4. Open dump.sql on vi and search and replace using :%s/domain.com/dev.domain.com/g
  5. Import dump.sql in the devdb
  6. Open prestashop cpanel and verify all shop url configuration is changed.
  7. Open phpmyadmin and check that all domain.com entries have changed to dev.domain.com
  8. Deleted files from /cache/smarty/compile /cache/cachefs
  9. Rebuild .htaccess file from prestashop.
  10. Changed login credentials in the devdb so that the website will load that one

Now the problem is that when I open dev.domain.com i still get redirected to domain.com and I'm at a loss as to what to try next.

Searching for domain.com in phpmyadmin in the devdb doesn't yield results grep -ri 'domain.com' * doesn't yield results either in the files

Any suggestions what I can try next?

PS: domain.com and dev.domain.com are two different domains. Not similar in anyway

Jumper answered 22/5, 2015 at 13:36 Comment(3)
remove your browser cache completly and check?Cosimo
Again if problem is not solved check link :- prestashop.com/forums/topic/…Cosimo
Thank you very much it was indeed firefox cache for redirects. Normal cookie deletion in each respective domain didn't work so I didn't check it further but it seems that resetting the cache fully fixed the issue. I really appreciate your helpJumper
C
3

First of all it's great that you follow each step in correct manner. Now the problem is:-

When ever you are running any domain on your browser. Browser create cache and cookie for this. If you change any setting of your domain, it will not reflect till you not clear your browser cache and cookie completely.

So just remove your browser cache and cookie and try to check is it working or not.

Note:- Based on your process that you follow, this only problem seems to exist.

Cosimo answered 22/5, 2015 at 13:54 Comment(2)
Thanks again for your help. It's always the simple things that we forget doing :)Jumper
correct often happen this type of thing. thanks for marking.:):):)Cosimo
C
16

For prestashop 1.7 you have to modify some values in the database:

  • ps_configuration table and change PS_SHOP_DOMAIN and PS_SHOP_DOMAIN_SSL to your new domain name, e.g. mydomain.com
  • ps_shop_url table and change again ‘domain’, ‘domain_ssl’ fields to your new domain name and ‘physical_uri’. If you copied files into root folder, the path will be simply ‘/’.

More on https://blog.premium-templates.eu/how-to-move-prestashop-from-localhost-to-domain-or-vice-versa

Note: browsers cache redirections, you will have to clean your browser cache. Check https://www.getfilecloud.com/blog/2015/03/tech-tip-how-to-do-hard-refresh-in-browsers/ to know how to do a "hard refresh" for your browser.

Cateran answered 2/8, 2017 at 22:27 Comment(1)
Thanks for offering advice on this matter, however in my case every entry in the database was changed to the correct url since I did a global search and replace on the db sql dump and it was just a caching issue. However you're giving me a chance to mention exactly which part of the cache I should have cleared.It was in Tools -> Options -> Advanced -> Network -> Cached Web ContentJumper
C
3

First of all it's great that you follow each step in correct manner. Now the problem is:-

When ever you are running any domain on your browser. Browser create cache and cookie for this. If you change any setting of your domain, it will not reflect till you not clear your browser cache and cookie completely.

So just remove your browser cache and cookie and try to check is it working or not.

Note:- Based on your process that you follow, this only problem seems to exist.

Cosimo answered 22/5, 2015 at 13:54 Comment(2)
Thanks again for your help. It's always the simple things that we forget doing :)Jumper
correct often happen this type of thing. thanks for marking.:):):)Cosimo
D
3

Your procedure is right, there is only a few factors that may cause your issue

  1. Make sure that there is no manual redirection in your web server configuration (or old .htaccess for Apache)
  2. Change Prestashop domains from the database (detailed below)
  3. Clear all your cache Update Prestashop domains from the database (detailed below)
  4. Always test with a browser in incognito/developer mode, disabling all cached redirections. I personally use an incognito Chrome window, in developer mode
  5. When debugging, it is a good idea to inspect the logs from your webserver as well as the network exchanges from your browser to identify the source of the issue

Here are a few rudimentary scripts I use to automate the cache cleanup and domain change for Prestashop 1.7.

1. Change Prestashop's domain

Use a template file to generate a .sql file to patch the database. If more convenient, you can manually run that on your database directly.

patch-domain.sql.template:

UPDATE ps_configuration SET value='${SHOP_DOMAIN}' WHERE name='PS_SHOP_DOMAIN';
UPDATE ps_configuration SET value='${SHOP_DOMAIN}' WHERE name='PS_SHOP_DOMAIN_SSL';
UPDATE ps_shop_url SET domain='${SHOP_DOMAIN}', domain_ssl='${SHOP_DOMAIN}';

Generate the real .sql patch file, and apply it

$ export SHOP_DOMAIN=mydomain.com
$ envsubst < patch-domain.sql.template > patch-domain.sql
$ mysql -u <username> -p <database> < patch-domain.sql

2. Clear Prestashop cache

Remove all cache files except index.php

clear-cache.sh:

#!/bin/bash
base_dir='./shared/prestashop/html'

# Clear class index in case any override changed
rm ${base_dir}/cache/class_index.php

declare -a cache_dirs=(
    "cache/smarty/compile"
    "cache/smarty/cache"
    "cache/cachefs"
    "img/tmp" # You might want to keep tmp images
    "themes/*/cache"
    "var/cache")

# Clear all cache folder, ignoring 'index.php'
for dir in "${cache_dirs[@]}"
do
    echo Cleaning ${base_dir}/${dir}...
    find ${base_dir}/${dir} -type f ! -name index.php -delete
done

EDIT: The updated gist is accessible here

Deanery answered 28/1, 2019 at 0:25 Comment(0)
A
0

Clear browser cache, nothing to see with this error, the real answer is change PS_SHOP_DOMAIN and PS_SHOP_DOMAIN_SSL in ps_configuration and ps_shop_url table

Argal answered 9/11, 2018 at 14:9 Comment(0)
K
0

This is an old post but maybe someone will be helped

  1. follow these steps : https://zemez.io/prestashop/support/how-to/prestashop-1-7-transfer-website-one-domain-another/

  2. In parameters.php change the date also to actual

  3. In config/defines.inc set define('PS_MODE_DEV', true); so admin panel will not be a blank page

Finish

Kamilah answered 25/3, 2021 at 17:58 Comment(0)
E
0

Comment lines from 469 to 472 in /classes/controller/FrontController.php section named "Automatically redirect to the canonical URL if needed"

Helped me. I did dozens of presta migrations and in one I had this problem like you. This helped me, I found in through debug mode.

Epoch answered 20/11, 2023 at 14:12 Comment(1)
If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From ReviewPyne

© 2022 - 2024 — McMap. All rights reserved.