No image

Solved! Magento Admin Redirect Issue & 404

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.

Magento 2 Admin Panel Redirect Issue

You may get a URL that looks like this or just a 404.

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 with an admin frontname as admin_Demo .


sudo php bin/magento setup:store-config:set --base-url=""
sudo php bin/magento setup:store-config:set --base-url-secure=""

sudo php bin/magento config:set web/secure/base_url ""
sudo php bin/magento config:set web/secure/use_in_frontend ""
sudo php bin/magento setup:config:set --backend-frontname="admin_Demo"

Note: Use the trailing “/” and stay consistent with HTTP or HTTPS.