How to fix redirect issue in WordPress

Problem: By mistake user “Changed the WordPress address URL” in General Settings and now user cannot login nor access the admin page. User may not even access the database, but still user can access the login page i.e. site-name/wp-login.php

Solution: We can fix “Too many redirect issue” in various way without touch Database or without logging in to the website.

Before providing solutions, let me tell you how this problem occurs. Too many redirect issue is very common in WordPress and if you Google with these keywords, you will get hundreds of such posts on it. Well, main cause for this is misconfigured value or your WordPress URL as shown in below image:

wordpress address settings in general settings
wordpress address settings in general settings

Let’s assume your WordPress URL is and by mistake you wrote anything else but not this like
So, It will always be trapped in a loop to redirect your site from to and so on…

In Firefox you will see error like this (The page isn’t redirecting properly):

WordPress redirect error in firefox
WordPress redirect error in firefox

And in Chrome error will be like this (This webpage has a redirect loop):

WordPress redirect loop error in chrome
WordPress redirect loop error in chrome

Solutions To Redirect loop in WordPress

1. Fixing the “Too Many Redirect issue” by adding 2 lines in wp-login.php (usually it will be at wordpress_site/wp-login.php )  which will be used to reset the address:

//FIXME: do comment/remove these hack lines. (once the database is updated)
update_option(‘siteurl’, ‘’ );
update_option(‘home’, ‘’ );

Note: Once it is fixed, just remove these two lines from the file

2. Fixing the issue using wp-config.php (which does not need phpMyAdmin). 🙂
It is possible to set the site URL manually in the wp-config.php file.
Add these two lines to your wp-config.php, where “” is the correct location of your site. (Where WordPress is installed)


Note: This is not necessarily the best fix, it’s just hard coding the values into the site itself. So, You won’t be able to edit them in the General settings page any more when you are using this method to fix this issue. Once it is fixed just remove these two lines from the file.

3. Using Database through PHPMyAdmin

UPDATE wp_options SET option_value = '' WHERE option_name IN ('home', 'siteurl');

Hope this will help someone as it helped me and many of our clients.

Image Source:


Sanjeev Jaiswal

He loves web programming and security and co-founder of Alien Coders. He usually shares and helps engineering students and IT professionals in academics and jobs. An avid reader and quick learner.

Share your comment

%d bloggers like this: