Wordpress URL change upon migration to another domain
The easiest is to add it to "wp-config.php". Something like:
You can test it in curl
and see if it works:
URL change can be done via wp-cli
. Do the following:
Note that the above is a dry-run
or practice only. If x in not zero in the bottom statement of 'x replacements':
1~$ wp search-replace 'http://OLD_DOMAIN.com' 'http://NEW_DOMAIN.com' --dry-run
2+------------------+-----------------------+--------------+------+
3| Table | Column | Replacements | Type |
4+------------------+-----------------------+--------------+------+
5| wp_commentmeta | meta_key | 0 | SQL |
6| wp_commentmeta | meta_value | 0 | SQL |
7| wp_comments | comment_author | 0 | SQL |
8| wp_comments | comment_author_email | 0 | SQL |
9| wp_comments | comment_author_url | 0 | SQL |
10| wp_comments | comment_author_IP | 0 | SQL |
11| wp_comments | comment_content | 0 | SQL |
12| wp_comments | comment_approved | 0 | SQL |
13| wp_comments | comment_agent | 0 | SQL |
14| wp_comments | comment_type | 0 | SQL |
15| wp_links | link_url | 0 | SQL |
16| wp_links | link_name | 0 | SQL |
17| wp_links | link_image | 0 | SQL |
18| wp_links | link_target | 0 | SQL |
19| wp_links | link_description | 0 | SQL |
20| wp_links | link_visible | 0 | SQL |
21| wp_links | link_rel | 0 | SQL |
22| wp_links | link_notes | 0 | SQL |
23| wp_links | link_rss | 0 | SQL |
24| wp_options | option_name | 0 | SQL |
25| wp_options | option_value | 2 | PHP |
26| wp_options | autoload | 0 | SQL |
27| wp_postmeta | meta_key | 0 | SQL |
28| wp_postmeta | meta_value | 0 | SQL |
29| wp_posts | post_content | 2 | SQL |
30| wp_posts | post_title | 0 | SQL |
31| wp_posts | post_excerpt | 0 | SQL |
32| wp_posts | post_status | 0 | SQL |
33| wp_posts | comment_status | 0 | SQL |
34| wp_posts | ping_status | 0 | SQL |
35| wp_posts | post_password | 0 | SQL |
36| wp_posts | post_name | 0 | SQL |
37| wp_posts | to_ping | 0 | SQL |
38| wp_posts | pinged | 0 | SQL |
39| wp_posts | post_content_filtered | 0 | SQL |
40| wp_posts | guid | 3 | SQL |
41| wp_posts | post_type | 0 | SQL |
42| wp_posts | post_mime_type | 0 | SQL |
43| wp_term_taxonomy | taxonomy | 0 | SQL |
44| wp_term_taxonomy | description | 0 | SQL |
45| wp_termmeta | meta_key | 0 | SQL |
46| wp_termmeta | meta_value | 0 | SQL |
47| wp_terms | name | 0 | SQL |
48| wp_terms | slug | 0 | SQL |
49| wp_usermeta | meta_key | 0 | SQL |
50| wp_usermeta | meta_value | 0 | PHP |
51| wp_users | user_login | 0 | SQL |
52| wp_users | user_nicename | 0 | SQL |
53| wp_users | user_email | 0 | SQL |
54| wp_users | user_url | 1 | SQL |
55| wp_users | user_activation_key | 0 | SQL |
56| wp_users | display_name | 0 | SQL |
57+------------------+-----------------------+--------------+------+
58Success: 8 replacements to be made.
Proceeed and remove the '--dry-run' as follows:
Sometimes, this won't work and you'll notice an infinite redirect.
Just use the following:
Things will go back to normal.
NOTE: Going from http
to https
and vice versa is a URL change.