Transfer domain and rename redirect URLs using wp-cli

#462526
  • Resolved Nicohood
    Rank Math free

    Hi,
    I want to transfer my website from example.com to test.example.com. I use it as a temporary test site, which I reset and sync every midnight. I do migrate my whole wordpress database using wp-cli:

    wp search-replace 'https://example.com' 'https://test.example.com'

    Now I noticed that my redirect rules in RankMath are still pointing to the original domain, not the new one. Usually the wp-cli script should replace all occurences smart enough, but it does not work in this case. I was told by the developers that this might be an issue inside the plugin itself. Maybe those settings are not stored in the mysql database, or maybe deep inside json datatypes.

    https://github.com/wp-cli/wp-cli/issues/1592#issuecomment-1256897848

    Is that assumption true, or why can’t I simply rename those redirects? It would be nice if you could give me an explanation, workaround or proper solution.

    Also I am wondering if there are more things to change or reset when doing a domain migration. I can imagine that I need to reset the sitemap, but how can I do that using wp-cli?

    Thanks a lot 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Unfortunately, the destination URL are recorded in your database so this may require you to change it manually or you can make use of our bulk editor which is current for the PRO version. https://rankmath.com/kb/bulk-editing-in-rank-math/#redirect

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Okay, but if it is inside the database, why can’t wp-cli rename it? That’s what it is made for. Do you store it in a special format?

    Hello,

    We store the sources in a JSON-encoded way but the destination URL is a simple text field. The destination should be able to be changed with this function but the sources will always revert back to the domain of the website taken from the home_url() function.

    You can see how this is store in the database table: wp_rank_math_redirections.

    Don’t hesitate to get in touch if you have any other questions.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Transfer domain and rename redirect URLs using wp-cli’ is closed to new replies.