Fix Error Too Many Redirects Issue in WordPress

The “too many redirects” error is a common issue that WordPress users may encounter. It occurs when a browser is stuck in a continuous loop of trying to access a particular web page. This error can be frustrating for both website owners and visitors. In this article, we will provide a comprehensive guide on how to fix the “too many redirects” error in WordPress with both beginner and advanced level solutions.

Beginner Solution: Clear Your Browser Cache and Cookies

The first step in fixing the “too many redirects” error is to clear your browser cache and cookies. This is because your browser may be storing outdated or incorrect information, which can cause the continuous loop of redirects. To clear your browser cache and cookies, follow these steps:

  1. Open your browser and click on the three dots icon at the top right corner of the screen.
  2. Select “History” from the drop-down menu.
  3. Click on “Clear browsing data” on the left-hand side of the screen.
  4. Select the time range for which you want to clear your browsing data.
  5. Check the boxes next to “Cookies and other site data” and “Cached images and files.”
  6. Click on “Clear data” to clear your browser cache and cookies.

Advanced Solution: Check Your Website’s URL Settings

If clearing your browser cache and cookies doesn’t fix the “too many redirects” error, the next step is to check your website’s URL settings. Incorrect settings can cause your website to redirect continuously. To check your website’s URL settings, follow these steps:

  1. Log in to your WordPress dashboard.
  2. Click on “Settings” and then “General.”
  3. Check the WordPress Address (URL) and Site Address (URL) fields. Ensure that they are both set to the correct URL of your website.
  4. If the URLs are incorrect, change them to the correct URL and click on “Save Changes.”

Advanced Solution: Check Your Website’s .htaccess File

If the above solutions don’t fix the “too many redirects” error, the next step is to check your website’s .htaccess file. This file controls the server configuration for your website and incorrect settings can cause the continuous loop of redirects. To check your website’s .htaccess file, follow these steps:

  1. Connect to your website using an FTP client or file manager in your hosting account.
  2. Locate the .htaccess file in the root directory of your website.
  3. Rename the .htaccess file to something like .htaccess-backup.
  4. Try accessing your website again to see if the issue is resolved. If it is, then the problem was likely in the .htaccess file.
  5. Create a new .htaccess file by going to “Settings” and then “Permalinks” in your WordPress dashboard. Click on “Save Changes” to generate a new .htaccess file.

Too many redirects” error can be a frustrating problem, but it can be fixed with a few simple steps. By following the beginner and advanced level solutions outlined in this article, you should be able to resolve the issue and ensure that your website is accessible to all visitors. Remember, if you’re not comfortable making these changes yourself, it’s always a good idea to contact your web host or a WordPress developer for assistance.

Method 2

The “Too Many Redirects” issue in WordPress is often caused by incorrect configurations in the site’s settings, plugins, or server settings. Here’s a step-by-step guide to troubleshoot and fix this issue through coding:

1. Check WordPress Address (URL) and Site Address (URL)

Sometimes, a mismatch in these URLs can cause a redirect loop.

  • Log in to your WordPress dashboard.
  • Go to Settings > General.
  • Ensure both WordPress Address (URL) and Site Address (URL) are correct and consistent (e.g., both should start with https:// or both with http://).
  • If you can’t access the dashboard, you can update these URLs directly in the wp-config.php file:
            
              define('WP_HOME','https://yoursite.com');
define('WP_SITEURL','https://yoursite.com');
            
          

Replace https://yoursite.com with your actual site URL.

2. Check .htaccess File

If your .htaccess file is misconfigured, it can cause redirect loops. You can reset it by creating a default .htaccess file:

  1. Access your site via FTP or File Manager in your hosting control panel.
  2. Rename the existing .htaccess file to something like .htaccess_old.
  3. Create a new .htaccess file in the root directory of your WordPress installation and add the default WordPress rules:
            
              # BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
            
          

3. Disable Plugins

A plugin might be causing the redirect loop. To test this:

  1. Access your site via FTP or File Manager.
  2. Navigate to the wp-content folder.
  3. Rename the plugins folder to something like plugins_old.
  4. Check if the issue persists. If it doesn’t, one of your plugins is causing the issue.
  5. Rename the folder back to plugins and disable the plugins one by one from the WordPress dashboard to identify the culprit.

4. Check for SSL Settings

If you’ve recently switched to HTTPS, ensure that all configurations are correct:

  • In the wp-config.php file, force SSL if needed:
            
              define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
    $_SERVER['HTTPS']='on';
            
          
  • Ensure that your site is properly configured to use HTTPS in the WordPress settings.

5. Check Server-Side Redirects

If you have server-side redirects set up (like in nginx or .htaccess), they may conflict with WordPress.

For nginx:

  • Check your nginx.conf file for any conflicting redirects.

For Apache:

  • Ensure that any redirects set in the .htaccess file aren’t causing loops.

6. Clear Browser Cookies

Sometimes, clearing your browser’s cookies can resolve the issue, especially if the cookies have become corrupted or outdated.

7. Check CDN or Proxy Settings

If you’re using a CDN or proxy like Cloudflare, ensure that the redirect settings there aren’t causing a loop. For instance, setting the SSL mode to “Flexible” can sometimes cause this issue. Try setting it to “Full” instead.

8. Debugging Using WP-CLI

If you have access to WP-CLI, you can run the following commands to help identify the problem:

            
              wp option get siteurl
wp option get home
            
          

These commands will display the URLs configured in your database, and you can confirm they match what you expect.

By following these steps, you should be able to resolve the “Too Many Redirects” issue in WordPress. If the problem persists, it might be worth checking with your hosting provider or considering more advanced debugging techniques.