0

Help! I changed the domain of a website and now it sends me to a 404 error when i try to access my admin page. I don't have the files backed up. What can I do to reverse this?

1

2 Answers 2

1

Here are two options for you:

1) Do you have access to the WordPress database via PhpMyAdmin or similar? If so, you can change the information via the wp_options table in siteurl and home (inside the option_name column). Change both those and you should be good to go.

WARNING! If you make the change in the database be VERY careful not to touch anything else or you might mess up your whole WP database. I've attached screenshots so you can see the correct table/row to edit.

A good rule of thumb is, if you don't know what it is, don't touch it. If you don't feel confident doing this, try option 2.

Change siteurl option

Change home option

2) Do you have access to the hosting account or FTP? If so you can hard code the domain into WordPress in the wp-config.php file.

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

Save and/or upload the file and you should be able to log back into your system.

Important! This setting doesn't actually change the database settings, so if you delete the two lines of code you added to wp-config.php, you'll be back at square one. Only delete if you are able to eventually change the database (once you have defined WP_SITEURL and WP_HOME, you can no longer update those values in the database through WordPress)

Explaination from the WordPress codex:

"NOTE: It won't change the Database value though, and the url will revert to the old database value if this line is removed from wp-config. Use the RELOCATE constant to change the siteurl value in the database."

You can learn more about customizing the wp-config.php file here on the WordPress codex page

0

The above answer is actually the best answer, but if you're really wanting to change the domain name of your website permanently, you'll want to run a serialized search and replace script, which can be uploaded to your WordPress install root and ran through an internet browser.

It will grab your database credentials from the wp-config.php file automatically, you'll just want to enter the old URL and replace it with the new one on the second to last step. Remember, this is not reversible and you should only replace the smallest common value (e.g. replace oldtest.com with newtest.com, not http://oldtest.com/ with http://newtest.com).

This will update all instances of your URL, including attachment paths, which will be important if you're not running a root relative installation.

This is the tool I use, just be sure to delete it from your FTP when you're done.

1
  • 1
    And easier even, if you have SSH access, is the WP-CLI search-replace command.
    – Jan Boddez
    Sep 27, 2017 at 8:12

Your Answer

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

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