Diagnosing Redirect Issues

6 min read

Introduction

Undesired redirects can be frustrating to deal with. Fortunately, narrowing down the root cause of these issues can usually be done quickly when you know what to check. This article will walk you through the checks for 3 different scenarios:

  1. Your website is redirecting to different site or an internal page, or has a redirect loop
  2. Your website is redirecting all pages to wp-login.php
  3. Your website is redirecting back to the wp-login.php after logging in
  4. Your website is redirecting to wp-admin/setup-config.php
  5. Specific files are experiencing “too many redirect” errors

You may also want to check your site over at the following link to see if it offers any immediate insights:
https://www.redirect-checker.org/index.php

Your website is redirecting to different site or an internal page, or has a redirect loop

1. Check the Website in Incognito Mode

Check the site in an incognito window to rule out a browser issue with cookies or caching. If the site works correctly, clear your website’s browser cache.

2. Does the website have a Valid SSL?

If your website is loading over HTTPS but doesn’t have a valid SSL this can manifest in a few different errors. SSL related errors are much easier to pin down. Please see the troubleshooting steps in this counter-part article that details symptoms and causes for these errors:

Why do I see a different site than I’m supposed to, an SSL warning, signon.php, or too many redirects?

The above article covers the following:

  1. The “too many redirects” error caused by Cloudflare
  2. “Your session is finished” or a signon.php link
  3. Website is insecure warnings
  4. Your browser is trying to access a site without an SSL over HTTP and Nginx is returning the first website on the server that has one instead of your website

Number 1 is caused by Cloudflares flexible SSL setting, and 2, 3 and 4 are all easily solved by provisioning an SSL certificate.

3.1 Are The Database SITEURL and HOME Settings are incorrect?

If you’re being redirected to staging or a previous URL and routing for your domain is set to “None” (and not “root” or “www”), then you may have the incorrect address set within the database inside the wp_options table.

Previously, we used to strictly control these values. but so that third-party services such as Cloudflare APO, we now only control these values is when you specifically set either the root or www route type.

You can learn more about routing here:
Manage Site Domains and Site Routing (non www vs www)

To check, head to the Sites page inside your account, and open up PHPMyAdmin for your website by clicking the database icon:

Click through to the wp_options table:

Here make sure your siteurl and home are set correctly. If you need to edit them, simply click on the incorrect link to edit, and then press Enter when it is correct.

3.2 If it’s a multisite, check the wp_blogs table

If you’ve changed domains on a multisite, be sure to check the wp_blogs table.

4. Is there an Nginx configuration or .htaccess rule in place?

If you have migrated your website and you previously had a redirect setup in either an Nginx configuration file or .htaccess, then these settings will have carried over. Check and remove the redirects, then reload Nginx/OpenLiteSpeed.

5. Check Your DNS/CDN Configuration

Do you have any custom rules set up at your DNS provider or CDN that could be causing the redirect?

6. Do Permalinks need a refresh/reset?

We’ve seen migrations where the permalink settings have been changed. Check your settings are correct, re-save them, then clear the whole cache. Does this fix the issue?

7. Check Your Plugins

At this point, it’s almost certainly a plugin within your website.

If you deactivate all plugins (rename the plugin directory via SSH or SFTP) does this fix the issue? If yes, rename the folder back to “plugins” and deactivate them one by one until you find the culprit. Please see the following articles on how to connect to your servers:

Your website is redirecting all pages to wp-login.php

1. Check the Website in Incognito Mode

Check the site in an incognito window to rule out a browser issue with cookies or caching. If the site works correctly, clear your website’s browser cache.

2. Is the Force Login plugin active?

Have you migrated your website or pushed from staging to live? Check your website for Force Login plugin. Though rare, it’s possible that this failed to remove during the push. If you’ve migrated a different way (manually or via a plugin), then this will need deactivating.

Once deactivated, the redirect should disappear.

Your website is redirecting back to the wp-login.php after logging in

If you’re unable to login, check the following:

  1. Does changing the PHP version fix the issue? It could be an issue with a plugin inside the site not playing well with the PHP version –  test with PHP 7.3.
  2. If using OpenLiteSpeed, is there anything custom inside the .htaccess file?
  3. If you deactivate all plugins (rename the plugin directory via SSH or SFTP) does this fix the issue? If yes, rename the folder back to “plugins” and deactivate them one by one until you find the culprit.

Your website is redirecting to wp-admin/setup-config.php

This redirect occurs when the WordPress can’t find the wp-config.php file (which can be caused by a few different things). We’ve only seen this issue come up once on support, and below are the possible scenarios that we’re aware of.

1. Reset Your Permissions

Incorrect permissions are the most likely cause for this error. Head to the Tools page inside your account and run a permissions reset: 

  1. Select Quick Fixes
  2. Select the appropriate server
  3. Select the appropriate site (or staging site)
  4. Select Reset Permissions
  5. Click Start Task

2. Check Your Database

Check your websites htdocs folder. Is there an additional wp-config.php file? If yes, remove it or rename it.

3. Clear your cache

Clear both the website cache and your browser’s cache (or check in incognito).

Specific files are experiencing “too many redirect” errors

In one case in support, we saw a self-hosted (uploaded to the uploads directory) video background, that was failing to load, reporting “too many redirects” as the console error.

Pasting the filepath for that video into the Redirect Checker website revealed that this was a 302 taking place within WordPress.

The root cause ended up being an Nginx configuration that had been put in place for MemberPress, which has this line, putting rules in place that affect these file formats:

location ~* \.(zip|gz|tar|rar|doc|docx|xls|xlsx|xlsm|pdf|mp4|m4v|mp3|ts|key|m3u8)$ {

In this case it was an .mp4 file, which we edited out of this line. After saving the file and reloading Nginx, the video began to work correctly again.

Check your Nginx folder and any configs that you have manually added in /var/www/site.url/nginx.

If you’re unsure, you can send a ticket in to support with all the details – the error, the file, the website page, and the configs, and we can let you know if anything there might be responsible.