0

I'm looking for a way to quickly update all unsecure, secure, and cookie domain URLs through phpMyAdmin.

My situation is to change unsecure & secure URLs (I use always-on HTTPS)

from

https://www.website.com

to

https://staging.website.com

and change Cookie domains

from

www.website.com

to

staging.website.com

Is there a quick way I can reference the core_config_data table for a search and replace of www with staging in rows web/unsecure/base_url, web/secure/base_url, and web/cookie/cookie_domain ?

This would help to fool-proof any updates when staging is rebuilt from production and make it quicker than finding each row and updating manually.

I am aware of changes to be made in local.xml and flushing of cache - that's a simple task I can complete after running this Search & Replace command.

1 Answer 1

1

This should do the trick:

use [database-name];

update core_config_data
set value = replace(value, 'www', 'staging')
where path in ('web/unsecure/base_url', 'web/secure/base_url', 'web/cookie/cookie_domain');

And if you want to do a 'dry-run' just to check which old values will be replaced by which new values:

select value 'Old Value', replace(value, 'www', 'staging') 'New Value'
from core_config_data
where path in ('web/unsecure/base_url', 'web/secure/base_url', 'web/cookie/cookie_domain');
1
  • Awesome! The "dry run" worked perfectly. Thank you!
    – Steven J
    Sep 12, 2017 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.