Microsoft Azure Open Source Development Support Team Blog

Support for Open Source Technologies on Microsoft Azure App Service

WordPress: Redirecting to wrong URL!!


While trying to browse to, it keeps redirecting to!!


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 issue occurs due to URL settings on the database. There are two fields named SITEURL and HOME within the wp_options table that control the URL redirects.

2016-07-12 16_47_49-Start

Fig 1. MySQL Workbench showing URL settings from wp_options table



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:

A) *Recommended Method* Through WordPress Admin

1)  Login to WordPress Admin

2) Click on Settings -> General

01 - General

3) Find the WordPress Address (URL) and Site Address (URL) fields:

03 - Update URL

4) Update it to your new URL as shown:

04 - Updated URL

5) 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

3) Save wp-config.php file

4) In your browser, open wp-login.php on  your new site. Example: For the domain,, the URL would be:

5) Login

6) Verify the address bar is correct

7) In WordPress Admin, go to Settings -> General

01 - General

8) Verify WordPress Address (URL) and Site Address (URL) are correct

04 - Updated URL

9) Save changes

10) Go back to wp-config.php

11) 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.


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=’’

WHERE option_name = ‘home’



UPDATE wp_options

SET option_value=’’

WHERE option_name = ‘siteurl’