Error After Changing URLs in WordPress General Settings

David

March 6, 2014

Recently, a client decided to purchase an alternative domain name for their existing website. They decided to log into their WordPress dashboard and start poking around. They changed the WordPress Address and Site Address under General Settings to the new domain name. Needless to say, this wasn’t a good idea. After the changes were saved, the website was no longer functioning.

wordpress-general-settings

The site wasn’t displaying and I couldn’t access the WordPress login to get to the dashboard. In order to correct the issue, I needed FTP access so I could modify the wp-config.php and functions.php file.

The following code can be used to manually define a website URL through the wp-config.php file.

define('WP_HOME','http://www.yourdomain.com');
define('WP_SITEURL','http://www.yourdomain.com');

Within seconds the website was working.

However, I was faced with another issue. When I logged in to WordPress and went back to the General Settings, the text fields were disabled.

wordpress-general-settings2

In order to edit these fields, I added the following code to the top of the functions.php file, immediately after the initial “<?php” line.

update_option('siteurl','http://www.yourdomain.com');
update_option('home','http://www.yourdomain.com');

After I uploaded the new version of the functions.php file, I removed the code that was added to the wp-config.php file.

When I logged back into WordPress, the text fields under General Settings were editable.

The last step was to remove the code that I added to the functions.php file and the issue was solved.

Check out my previous post, which will show you how to use your .htaccess file to redirect an alternative domain.

Related Articles in Coding, WordPress,

Our Services for Law Firms


6 Responses to Error After Changing URLs in WordPress General Settings

  1. Silviu
    1:00 am on May 11th, 2015

    Done this and it’s not working. Tried both wp-config and functions.php method.

  2. Error After Changing URLs in WordPress General Settings – My Blog
    11:22 pm on July 23rd, 2017

    […] Error After Changing URLs in WordPress General Settings […]

  3. ibrahim
    5:47 am on August 3rd, 2017

    tried it out….wp-config change worked perfectly, but the functions.php change did not work….received everytime an error.

  4. Jonthan
    4:36 am on December 30th, 2017

    This is actually accurate except for one point, you should have mentioned that the functions.php file to be edited is not the one in wp-include but the one found in our current themes folder.
    https://www.tipsandtricks-hq.com/how-to-change-the-url-of-a-wordpress-site-6098

  5. Santosa Sandy
    1:32 am on January 31st, 2018

    I am fixing that problem by editing the site url in the sql database as suggested here https://www.digitalocean.com/community/questions/500-internal-server-error-after-changing-wordpress-url

  6. nitesh
    12:19 am on April 19th, 2018

    We are facing a wired issue , we are replacing the site url and home url in wp-config.php and database both .

    Webiste is redirecting to new url but showing message “page ok” .Also wp-admin is not opening after these changes .

    We refer all the below steps :

    checklist for wordpress migration is:

    edit database table wp-options and options siteurl and home there
    edit wp-config.php (DB_NAME, DB_USER, DB_PASSWORD a DB_HOST)
    use this replace script to replace all other occurences of absolute paths for relative path, it is enough to replace your old site name http://yoursite.com with an “/”
    also you want to regenerate static links, in Settings menu go to permalinks and just click on save.

    what to do in that case ??

Leave a Reply

Your email address will not be published. Required fields are marked *

*

 

X PaperStreet slider logo

Free Consultation

Impress & Get Results.

Want a “wow” site now?

Get a quote.