WordPress

How to fix WordPress wp-admin redirects me to a different domain?

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. Open your website’s wp-config.php file in cPanel File Manager or via FTP.
  2. 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');
      
  3. 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 Ace.
  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
Wordpress wp admin redirects me to a different domain Edited
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.
  2. 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');
      
  3. Upload the file back up to your web space, making sure to upload to the same location.
  4. 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
  5. Your web site should now load.
  6. 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.

Was this guide helpful?

Need help with this?

Open a ticket and link to this guide so our team can see what you have tried.

View support tickets

Power your business with Ecenica Hosting

Built for WordPress and serious websites. Fast, secure and supported by real people in the UK.

Ecenica hosting services represented by a connected red route across London