One of the most annoying aspects of caching and Magento’s FPC engine is sometimes you get an odd redirect when attempting to access the admin console. This can happen for many reasons, and the results are ususally Magento’s Admin console with a 404 or malformed URL.
You may get a URL that looks like this or just a 404.
http://192.168.29.156/admin_demo/http:/admin_demo/admin/index/index/key/70891b1fd78afeaa7cda1cd2caf873831789b15e90c9ae300f2a12f2cabf9538/
Possible Solutions
If you are using Redis, try from the CLI:
sudo redis-cli flushall
404s & Alternatives for other issues
Reset your frontend:
sudo php bin/magento setup:config:set –backend-frontname=”{frontend value}” #You can find the frontend in /apt/etc/env.php
sudo php bin/magento cache:flush config
By-Pass Cache Cloudflare Page Rule
Create a page rule, or a cache rule to bypass the CDN caching for the admin console. You’ll have to play with this rule depending on how you have Magento configured. This example rule below is defined, because we use static on an S3 bucket via S3R-Alpha.
Admin URL Reset
Reset both legacy paths and new paths, plus reset your admin frontname. In our example, our domain name is 245.amistacxdemos.io with an admin frontname as admin_Demo .
Legacy:
sudo php bin/magento setup:store-config:set --base-url="https://245.amistacxdemos.io/"
sudo php bin/magento setup:store-config:set --base-url-secure="https://245.amistacxdemos.io/"
2.4.0+
sudo php bin/magento config:set web/secure/base_url "https://245.amistacxdemos.io/"
sudo php bin/magento config:set web/secure/use_in_frontend "https://245.amistacxdemos.io/"
sudo php bin/magento setup:config:set --backend-frontname="admin_Demo"
Note: Use the trailing “/” and stay consistent with HTTP or HTTPS.
Lead_Robot