1

Aim

Update Domain Name of M2 instance from example.co to beta.example.com

Steps

So, I changed the Domain Name of my Magento 2 store using the following commands:

bin/magento setup:store-config:set --base-url="http://beta.example.com/"

bin/magento setup:store-config:set --base-url-secure="https://beta.example.com/"

bin/magento cache:flush

bin/magento cache:clean

Result

This worked fine, until the next day. When I tried to load my admin url (http://beta.example.com/admin), I was forwarded to the below URL with this error:

  • http://beta.example.com/admin/http:/admin/admin/index/index/key/1a2376cc1c89ea53ca4a903003d3a4859b5c62347cc763a6c0105ea3bae466e/
  • "This page isn’t working beta.example.com redirected you too many times."

Regardless of trying to load http://beta.example.com/admin after clearing cookies on different Browsers and Devices, I couldn't get past this point.

Temporary Workaround

In order to resolve this, I have to clear the cache by running the below commands.

bin/magento cache:flush

bin/magento cache:clean

This seems to work for a bit until I go to load the backend the next day. I can't even reproduce the error until the next day...

Any ideas what could be causing this? Or even why my temp workaround only works for a few hours?

Notes: Day 1

The only thing I can think of that happens overnight is Indexing (maybe). So, I've ran the below command. Will report back in 24 hours

bin/magento indexer:reindex

Notes: Day 2

Indexing had no affect. Admin URL still reset to "broke" the next day. I'll try clearing all cache folders today using the below command. Will report back in 24 hours

rm -rf var/page_cache var/cache var/generation var/div var/view_preprocessed generated/metadata/* generated/code/*

Notes: Day 3

No affect. Tried updating Admin URL to see if that does anything with:

bin/magento setup:config:set --backend-frontname="admin_path"

Notes: Day 4

No affect.

Notes: Day 5

I've narrowed down that it's config that requires either Cleaning of Flushing with either command.:

bin/magento cache:clean config or bin/magento cache:flush config

I've yet to determine what changes over ~24hrs for me to have to keep doing this though.

1
  • What you have here Log in to the Admin Panel, choose Stores>Settings>Configuration. And in app/etc/env.php in admin line
    – BartZalas
    Aug 20, 2018 at 10:34

1 Answer 1

0

Having checked the DB Table (core_config_data), I noticed that my base URL was correct, so I never thought anything of it. I then realised after that the web/unsecure/base_url and web/secure/base_url entries were for scope_id = 1. There was no entry for scope_id = 0.

So, what I did was simply go into the backend of Magento to Stores > Configuration > General > Web and Press the Save Config button.

This then generated 2 new records in the core_config_data table under scope_id = 0. Since then, I've not come across the issue. Based on the fix, I'm surprised the problem didn't stop me from accessing any of the site at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.