Learn how to fix wp-admin redirecting to another domain name by updating your wp-config file and WordPress database.

Update WordPress Config File

First step is to edit your wp-config.php file to override the WP_SITEURL and WP_HOME values.

  1. FTP into your web space.
  2. Open wp-config.php
  3. Add the following lines of code, swapping https://www.example.com with the URL of your home page.
      define( 'WP_SITEURL', 'https://www.example.com');
      define( 'WP_HOME', 'https://www.example.com');
  4. Save and publish the file to your web space.

Update WordPress Database

Next step is to update your WordPress database to use the same domain you’ve set in your wp-config.php file.

** Update using phpMyAdmin **

  1. Open your WordPress database. Use phpMyAdmin or an app like Sequel Pro.
  2. Find the table called wp-options.
  3. Find the option_name called siteurl.
  4. Change the option_value to match the URL of your home page. eg http://www.example.com
wp_options table in phpMyAdmin
wp_options table in phpMyAdmin

** Update using functions.php **

If you have FTP access, or access to the File Manager in cPanel, you can update the domain using the following code.

  1. FTP in to your web space and download a copy the active theme’s functions.php file. The path will be something like /wp-content/themes/mytheme/functions.php.
  • Add the following lines of code on a new line immediately after the opening <?php, swapping https://www.example.com with the URL of your home page.

      update_option( 'siteurl', 'https://www.example.com');
      update_option( 'home', 'https://www.example.com');

  • Upload the file back up to your web space, making sure to upload to the same location.

  • Open your browser and load your WordPress login screen a couple of times using the domain saved above. eg https://www.example.com/wp-login.php

  • Your web site should now load.

  • Repeat steps 1 to 3, but this time remove the new lines. For performance reasons it’s important not to leave these lines active on a live website.