Too many redirects in Magento 2.3.3
-
25-03-2021 - |
سؤال
I am trying to migrate a magento version 2.3.3 site / system from one server to another.
After doing everything I should do to complete the migration I am getting 302 as a server response once after another. A targeting loop.
I have already tried some solutions such as changing the values of the config table core_config_data
.
path | value
web/seo/use_rewrites | 1
web/unsecure/base_url | http://exemple.com/
web/secure/base_url | https://exemple.com/
web/secure/use_in_frontend | 1
web/secure/use_in_adminhtml| 1
web/url/redirect_to_base | 0
web/cookie/cookie_path | NULL
web/cookie/cookie_domain | NULL
web/cookie/cookie_httponly| 0
I looked into .htaccess to see if there was something that was redirecting and found nothing either. I leave the link to it here: https://pastebin.com/30LDUsb5
After thinking it was all right, I ran php bin / magento c: c
. And perhaps another important piece of information, magento is using Redis for front and backend sessions and caching. The server I set up has a Redis server available but it is empty, magento can populate it from scratch.
Thank you in advance for any light.
المحلول
Explanation:
Your frontend is using http
, but in your config you've set it to force https in frontend (web/secure/use_in_frontend value 1, meaning "yes/true"). Therefore by visiting https, magento2 redirects to http, but the http reads the m2 config and goes back to https. Hence the loop.
Solution 1:
Try setting web/secure/use_in_frontend
to 0
php bin/magento config:set web/secure/use_in_frontend 0
and clear the cache:
php bin/magento cache:clean
Confirm the changes:
php bin/magento config:show web
Solution 2:
Another way to resolve this is to set your web/unsecure/base_url
from http to https
.
If the redirect still persists with use_in_frontend as 0, try in a new private/incognito window or clear your cache and try again, or even another PC/mobile or a different network (your mobile 3G), as redirects sometimes persist and need clearing local system dns caches etc.