2

I've made a copy of a Magento folder to set up another domain, swapped the old domain name both in the database (web secure url) and in the filesystem (env.php), and pretty much everywhere I could find it (did a recursive case-insensitive grep for the subdomain name and a search in the database dump) but I'm still getting a 301 redirect to the original website. Where could it be hiding? There are no traces of the old name in the filesystem except some references in the css files and no references to it at all in the database. I've hacked the redirect php files and it seems to occur inside Magento. Here's the trace (url name changed):

string(27) "https://old.webstore.com/"
#1 Magento\Framework\App\Response\Http\Interceptor[Magento\Framework\HTTP\PhpEnvironment\Response]#00000000000002390000000000000000#->setRedirect() called at [generated/code/Magento/Framework/App/Response/Http/Interceptor.php:149]
#2 Magento\Framework\App\Response\Http\Interceptor#00000000000002390000000000000000#->setRedirect() called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:91]
#3 Magento\Store\App\FrontController\Plugin\RequestPreprocessor#000000000000022f0000000000000000#->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#4 Magento\Framework\App\FrontController\Interceptor#00000000000001750000000000000000#->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:75]
#5 Magento\PageCache\Model\App\FrontController\BuiltinPlugin#000000000000019f0000000000000000#->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#6 Magento\Framework\App\FrontController\Interceptor#00000000000001750000000000000000#->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#7 Magento\Framework\App\FrontController\Interceptor#00000000000001750000000000000000#->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:23]
#8 Magento\Framework\App\FrontController\Interceptor#00000000000001750000000000000000#->dispatch() called at [vendor/magento/framework/App/Http.php:116]
#9 Magento\Framework\App\Http\Interceptor[Magento\Framework\App\Http]#000000000000009d0000000000000000#->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:23]
#10 Magento\Framework\App\Http\Interceptor#000000000000009d0000000000000000#->launch() called at [vendor/magento/framework/App/Bootstrap.php:264]
#11 Magento\Framework\App\Bootstrap#000000000000000b0000000000000000#->run() called at [pub/index.php:30]
3
  • Based on your trace if your system still redirects to old domain, please check following in MySQL SELECT * FROM core_config_data WHERE path LIKE 'web/%secure/base_url'; Commented Aug 29, 2022 at 20:43
  • Of course to be sure you don't have domain in app/etc/env.php. Don't forget to flush Magento cache after any configuration changes. Commented Aug 29, 2022 at 21:03
  • app/etc/env.php was hiding something after all Commented Aug 29, 2022 at 21:16

2 Answers 2

0

A gotcha moment, thanks to Victor in the comments.

app/etc/env.php contained a reference to an old database that was copied and replaced with a new one. So the fix was to change the database name.

0
  1. You have to change the db settings in env.php like db name, db user and db password

  2. Go to your database and run this query

    select * from core_config_data where value like '%http%';

  3. Change the old domain URL to new domain URL.

Your Answer

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

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