Change wordpress site URL

From Notes_Wiki
Revision as of 13:29, 8 September 2016 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb>Wordpress_configuration|Wordpress configuration</yambe:breadcrumb> =Change wordpress site URL= In a working wordpress site /wp-admin can help in changing si...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb>Wordpress_configuration|Wordpress configuration</yambe:breadcrumb>

Change wordpress site URL

In a working wordpress site /wp-admin can help in changing site URL. However if a wordpress site is no longer functioning because site URL has changed then use following steps to change wordpress site URL use:

  1. Edit wp-config.php and append
    define('WP_HOME','http://example.com');
    define('WP_SITEURL','http://example.com');
    Note that this is not ideal as this fixes the site URL and later this cannot be changed via settings page. Updating wp_options database table option_name siteurl and home is better.
  2. Search for old URL everywhere using 'grep -r old-url *' and replace using
    find . -type f -exec sed -i "s/old-url/new-url/g" '{}' \;
    in all sub-folders and files recursively.

Refer https://codex.wordpress.org/Changing_The_Site_URL