Magento admin login getting redirected

Magento admin login getting redirected

July 2, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento admin login getting redirected

Solving Magento Admin Redirect Issues After Server Transfer

Transferring an e-commerce site like Magento from one server to another can be a complex process. One of the most common issues merchants face is being redirected back to the old domain when trying to log in to the admin panel.

Understanding the Redirect Loop Issue

When you transfer your site, the database and files are usually copied over as is. However, if the core configuration files or the .htaccess file still contain references to the old domain, the system will try to redirect all requests back there whenever you attempt to access anything using the new domain.

Location of Relevant Files

The key files that could be causing this issue are:

  1. index.php: This is the primary entry point for Magento. You can find it in your Magento root directory.
  2. .htaccess: Located in the same root directory, this file contains Apache rules managing URL rewrites and other server-level configurations.

Step-by-Step Solution

1. Verify Your Database Connection

First, ensure that your database connection settings are correct. Open your app/etc/local.xml file and update the <db_host>, <db_name>, <db_user>, and <db_password> values to match your new database credentials.

[Learn more about configuring Magento databases at https://laravelcompany.com/guides/magento-database-configuration.]

2. Update Domain in Core Config Files

Next, you need to update the domain name in several core configuration files:

  • app/etc/local.xml: Change both instances of the old domain under <web> tags.
  • app/code/core/Mage/Core/Model/Store.php: Replace any occurrences of the old domain.

3. Clean the Cache and Reindex

After updating the configuration, clear your cache by running these commands:

php bin/magento cache:clean
rm -rf var/cache/*

Then reindex all data:

php bin/magento indexer:reindex

4. Update .htaccess File

Open your .htaccess file and ensure that the following lines are present and correctly configured:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^your-old-domain\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.your-old-domain\.com [NC]
RewriteRule ^(.*)$ "http\:\/\/your-new-domain\.com\/$1" [R=301,L]

Replace your-old-domain.com with your previous domain and your-new-domain.com with the new one.

Resolving Core URL Rewrite Issues

If you’re still facing redirection issues, it might be due to core URL rewrite rules. You can manually clean them up by running:

php bin/magento indexer:reindex url_rewrite

Then, clear your cache again using the commands above.

Conclusion

Remember that migrating a Magento site requires careful attention to detail. Always back up your data before making changes, and test everything thoroughly on a staging environment first.

By following these steps and ensuring all relevant files are updated with the new domain, you should be able to successfully log in to your new server’s admin panel without any redirection issues.

If you’re looking for more advanced migration techniques or need help with other aspects of Magento development, feel free to visit our Magento development services page for expert assistance.

Database Admin Configuration SEO

Our network