WordPress: Redirecting to wrong URL!!

2 minute read | By Mangesh Sangapu


While trying to browse to http://www.example.com, it keeps redirecting to http://example.azurewebsites.net!!  

Redirection Scenarios

There are a couple situations where one may face the WordPress Redirection issue:

  • Migrated from another host
  • Changed your custom domain name and it’s going to your old domain!


Understanding The Issue

This redirection can occur for two reasons:

  1. URL settings on the database. There are two fields named SITEURL and HOME within the wp_options table that control the URL redirects.
  2. Defined constants in wp-config.php

2016-07-12 16_47_49-Start

MySQL Workbench showing URL settings from wp_options table


Wp-config.php showing defined constants affecting URL Redirection. To update these URLs, follow (C).

Stopping The Redirection (and taking control of the site)

Not everyone is comfortable with making updates on a database so there are several _options given below.   Here are a _few methods to fix this issue:

1. Login to WordPress Admin

2. Click on Settings -> General

01 - General

  1. Find the WordPress Address (URL) and Site Address (URL) fields:

03 - Update URL

  1. Update it to your new URL as shown:

04 - Updated URL

  1. Save Changes

05 - Save Changes

B) If you no longer have access to WordPress admin, set the site in “Relocate” mode within wp-config.php

  1. Edit wp-config.php

  2. Before the comment line “That’s all, stop editing!”, insert a new line: define(‘RELOCATE’, true);

2016-07-13 11_20_57-Diagnostic Console - Internet Explorer

  1. Save wp-config.php file

  2. In your browser, open wp-login.php on  your new site. Example: For the domain, http://www.mysite.com, the URL would be: http://www.mysite.com/wp-login.php

  3. Login

  4. Verify the address bar is correct

  5. In WordPress Admin, go to Settings -> General

01 - General

  1. Verify WordPress Address (URL) and Site Address (URL) are correct

04 - Updated URL

  1. Save changes

  2. Go back to wp-config.php

  3. Remove the define from step #2.

C) If you are unable to log into WordPress Admin, define new settings within wp-config.php

Note: This will hardcode the URLs and they will be disabled through the WordPress Admin -> Settings -> General Area. Because of this reason, it is not recommended.

define(‘WP_HOME’,’http://example.com’); define(‘WP_SITEURL’,’http://example.com’);

D) Manually update the HOME and SITEURL through a client like MySQL Workbench or PHPMyAdmin

Apply the following two queries to your WP_OPTIONS table:


UPDATE wp_options

SET option_value=’http://www.newaddress.com’

WHERE option_name = ‘home’



UPDATE wp_options

SET option_value=’http://www.newaddress.com’

WHERE option_name = ‘siteurl’



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