Prestashop: The Changing of the URL

August 18, 2019

We all know the feeling. Whether it’s hosting or trousers, the time comes when you know you have to make a change.

If your trousers are too tight you can try eating less or, heaven forfend, admit defeat and move into a bigger pair. Hosting, similar: if your site attracts lots of visitors there is only a certain distance that slimming down by optimising the settings will take you. Sometimes you just need a host with a bit more to offer. Maybe you should bite the bullet and make the move?

Why Would You Want to Change the URL of Your Prestashop Site?

The scenario is this. You want to move your site. But you only want to set it live in its new home if you can be sure it is going to work OK there. So what you need to do is to copy the site and all its data. Then having made all the necessary changes to ensure stuff like database connections work you can use a “Testing” or “Default” or “Staging” URL to check that your site is functioning in its new home like you think it ought.

Of course, there ought to be no reason why it won’t work, but this is the real world. There are a lot of variables, a multitude of traps to catch out the unwary and inexperienced. You really need to try on the hosting trousers to see if they’ll fit before appearing publicly on stage.

The Ideal Way

In the administration section of the website,

  • Go to the Configure section,
  • Click on Shop Parameters,
  • Click on Traffic & SEO.
  • Scroll down the page and you’ll see a section called Set Shop URL.

Simply put the Testing URL in there, click Save and you should be good to go.

When the Ideal Way Doesn’t Work

There can be any number of reasons. Usually you’ll be able to enter the admin site using the new Testing URL and just adding the admin path to that. The log-in process will whinge at you that you’re not using the prescribed URL, but you can ignore that. Once in you follow the steps above and proceed with your testing.

The front end requires that the URL be set to the Testing URL because it redirects everything to the URL in the Shop Parameters settings.

If you have a problem that is causing the White Screen of Death then the ideal way becomes moot. You’re going to have to get low and dirty and deal with the situation on its own terms. At times like this we’re all likely to turn to that self-proclaimed saviour, The Man on the Internet™

What The Man on the Internet Says

The problems with The Man on the Internet are many. Sometimes his advice is good. Often it is dated. And a lot of times he seems to have copied it from Other Men on the Internet as the solutions all bear an uncanny similarity in the way they are worded.

The Man on the Internet will tell you to access the database using your preferred method and seek out the ps_configuration table. Search for the records with a name like PS_SHOP_DOMAIN. This is the query that will find them:

SELECT * FROM `ps_configuration` WHERE name like '%PS_SHOP_DOMAIN%' 

You should get two results, one plain and one for SSL. Change the value field(s) to your testing URL.

If you don’t have SSL enabled on the testing URL then find the records where SSL is set for your shop using this query:

SELECT * FROM `ps_configuration` WHERE name like 'PS_SSL_ENABLED%' 

Change the values of PS_SSL_ENABLED and PS_SSL_ENABLED_EVERYWHERE to 0

Why The Man on the Internet is an Idiot

That advice is OK, as far as it goes. But The Man on the Internet is probably recalling his experiences with an earlier version of Prestashop. Prestashop 1.7 has another table ps_shop_url and it is to this that you should also look to change the domain to the Testing URL.

The fields that you should change are domain and domain_ssl.

Hold on - I’m being a Man on the Internet Now!

Strictly speaking, when you set up Prestashop the first time you can choose how the table names are prefixed. So it may not be ps_configuration or ps_shop_url, it could be ANY_PREFIX_configuration or ANY_PREFIX_shop_url. I was just trying to keep it simple.

If That Doesn’t Work

If, after all that, you are still getting redirects to the original site, you need to check:

  1. Your .htaccess file
  2. Try using incognito, guest mode or private browsing just to see if it’s your browser remembering the re-direct.

Hopefully, though you are now seeing your e-commerce Prestashop website in all its glory and have no problems and errors before setting the site live.

Still Stuck?

You can always seek help - why not contact me?

Conclusion

I am a little surprised that the Prestashop Team haven’t adhered to the Don’t Repeat Yourself (DRY) principle. Here we have the same things set in 2 different places. Unless you change them both you are not guaranteed to get predictable results. This is not unique in the core of Prestashop. The charitable explanation is that they are moving from one to the other, but have to keep the old in place for reasons of backwards compatibility, so as not to break something that depends on things being in a particular place.

Take Care™