Get a Free Consultation

    Search for:

    How to solve the ‘too many redirects’ issue in Magento 2?

    Last Updated | April 26, 2024

    Encountering the ‘too many redirects’ error in your Magento 2 store can be frustrating. This guide provides actionable steps to diagnose and resolve this issue effectively.

    If you’re seeing the ‘ERR_TOO_MANY_REDIRECTS‘ message on a page in your Magento 2 store, the first step is to clear cache and cookies. Additionally, verify if the error persists across different browsers.

    See Also: How to fix “Invalid form key. Please refresh the page.” error in Magento 2

    Analyzing Redirects with Developer Tools

    Use Developer Tools to inspect redirects. Press F12, navigate to the Network tab, and refresh the problematic page to view a list of redirects. This insight helps determine if redirects are occurring between multiple destinations or looping back to the same URL.

    too many redirects

    Testing with cURL

    You can test your website’s redirects using cURL, a script compatible with Unix-like systems.

    Follow these steps to analyze redirects:

    for site in $@; do
    echo --------------------
    echo $site
    echo --------------------
    curl -sILk $site | egrep 'HTTP|Loc' | sed 's/Loc/ -> Loc/g'


    ./redirect_checker.sh http://www.example.net
    HTTP/1.1 301 Moved Permanently
    -> Location: https://www.example.net/
    HTTP/1.1 301 Moved Permanently
    -> Location: http://www.example.net/
    HTTP/1.1 301 Moved Permanently
    -> Location: https://www.example.net/
    HTTP/1.1 301 Moved Permanently
    -> Location: http://www.example.net/
    HTTP/1.1 301 Moved Permanently

    Understanding .htaccess Redirects

    Magento 2 often utilizes .htaccess for URL rewriting and redirection.

    Here are examples of common redirections found in the .htaccess file:

    1. Force HTTPS

    RewriteEngine On

    RewriteCond %{HTTPS} off

    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    2. Force non-www

    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^www\. [NC]

    RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    3. Force www

    RewriteEngine On

    RewriteCond %{HTTP_HOST} !^www\. [NC]

    RewriteRule (.*) http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    Configuring Redirects in Magento 2

    To resolve the issue of excessive redirections in Magento 2, administrators should adjust settings in either local.xml or env.php.

    Additionally, it’s possible to establish a prefix for Magento 2 database table names. The primary table, typically named core_config_data, contains various configurable URLs, all of which include a base_url.

    To execute this, use the following command:

    select * from core_config_data where path like “base_url”

    | config_id | scope | scope_id | path | value |

    | 3 | default | 0 | web/unsecure/base_url | http://www.xyz.com |

    | 4 | default | 0 | web/secure/base_url | http://www.xyz.com |

    To modify the base_urls within the Magento 2 database, execute the following command:

    update core_config_data set value=”https://www.abc.com” where path like “web/.*/base_url”

    Final thoughts

    Overcome the obstacle of ‘ERR_TOO_MANY_REDIRECTS’ to enhance the performance of your Magento 2 store. By implementing the outlined measures for diagnosing and resolving redirect issues, you can guarantee a smooth browsing journey for your customers while safeguarding your store’s SEO integrity.

    See Also: Safeguarding Your Ecommerce Store With Magento 2 Development Services


    How do I properly implement Magento 301 redirects?  

    Magento 301 redirects are essential for maintaining SEO and preserving page rankings when URLs change. Follow Magento’s guidelines to set up 301 redirects correctly.

    What are some tips to minimize URL redirects for faster site loading? 

    Minimizing URL redirects can improve site performance and user experience. Avoid unnecessary redirects, regularly audit your website for outdated redirects, and optimize plugin usage.

    How do I create and use Magento 2 redirect types (301 & 302)? 

    Magento 2 supports both 301 and 302 redirects for URL management. Utilize the Admin panel’s URL rewrite feature to set up redirects and specify the redirect type accordingly.

    Why does the ‘too many redirects’ error occur in Magento 2? 

    The ‘too many redirects’ error typically occurs due to misconfigurations, faulty plugins, or conflicts in the .htaccess file. Diagnose the root cause to implement effective fixes and prevent recurrence.


    Almost 10 Years of experience in web development and more specifically 7 years of experience in eCommerce on Magento platform. Core experties are PHP, MySql, Laraval, CodeIgniter, React, Knockout JS, Rest/Soap, graphQL & Magento 1&2 feature development and customizations