The error “too many redirects” means that the website keeps being redirected between different addresses in a way that will never complete. Often this is the result of competing redirects, one trying to force HTTPS (SSL) and another redirecting back to HTTP (non-SSL), or between www and non-www forms of the URL.

Resolving the error too many redirectsIf you are using a CMS like WordPress, Magento, etc., that utilizes a base_url or URL type configuration within the site, you can end up with the configuration in the code or database conflicting with a redirect in a .htaccess file. These conflicting redirects will flip flop back and forth and never complete.

Your browser protects you from this by only allowing a certain number of redirects (often ten or so) before it gives up and reports the error message “too many redirects.” This shows up differently between Chrome, Firefox, and other browsers.

Redirects in the .htaccess File

The .htaccess file is a configuration file used to modify Apache server behavior per directory on a website/server. This is a user-level configuration file, and only some Apache configurations can be edited here, though redirects are common use.

You can have multiple .htaccess files that cascade over a series of directories. If you have a .htaccess in a parent directory, and another in a sub-directory they will both affect the sub-directory.  In these instances, it is important to remember where you do and do not have .htaccess files, to prevent conflicts between .htaccess files at different levels.

Below are a series of redirect examples and will aid in identifying redirects in your .htaccess file. These are not the only ways to do these kinds of redirects, but these should show you what the most common redirects look like so that you can recognize them if they are in a .htaccess file you are working with.


The .htaccess code below first checks if the request came into the server using HTTP or HTTPS. If the request did not use HTTPS, then the configuration will tell the browser to redirect over to the HTTPS version of the same website and URL that was requested before.


The WordPress CMS uses a .htaccess file for rewriting URLs to the index.php file, but it defines the URL of the website as a value in the database. If you do not already know the name of the database that is being used on the site, you can look it up in the main configuration for WordPress (wp-config.php).

You can also open the file in a text editor and look for these values, but from an SSH connection, you can use the program grip. This gives you more than just the database name, but the database name is the most important for what we need to do next.

Wrapping it All Up

With URLs configured in the database, as shown above, it is worth noting that these CMSs also provide their own redirect methods within the site code. If, for example, you have a .htaccess redirect that is redirecting to a URL that does not align with what is in the database, you can end up with the infinite redirect loop as described earlier. However, you now know what some common .htaccess redirects look like and where to find the configured URLs in some CMS software database. You are also well equipped to test, investigate, and confirm if these things are working in concert or working against one another, and some steps to resolve them.

Need our help contact us