Magento admin URL not working: 404 after changing it, can't go back

Magento admin URL not working: 404 after changing it, can't go back

September 26, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento admin URL not working: 404 after changing it, can't go back

Solving Magento Admin URL Issues: A Comprehensive Guide

If you’ve ever attempted to change your Magento admin URL only to be met with an infuriating 404 error page, you’re not alone. This common issue can leave even the most seasoned developers scratching their heads. In this guide, we’ll explore a step-by-step solution that should resolve your problem once and for all.

Understanding the Magento Admin URL Structure

Before diving into the solution, let’s briefly understand how Magento handles admin URLs. By default, the admin URL is structured as http(s)://<your-domain>/admin/. When you attempt to change this via the backend configuration, Magento updates several key components:

  1. The core_config_data database table
  2. The .htaccess file in your Magento root directory
  3. The cache files (which may include references to the old admin URL)

The problem typically arises when one or more of these components are not properly updated or cleared.

Step 1: Locate and Update the core_config_data Table

The first step is to locate any entries related to your previous admin URLs in the core_config_data table. This table stores all Magento configuration data, including the admin URL settings.

SELECT * FROM core_config_data WHERE path LIKE '%admin%';

Look for entries with paths like:

  • admin/url/use_custom
  • admin/url/custom_path

Update these pathways to match your new admin URL (in this case, “gestion”).

Step 2: Clear the Magento Cache

After updating the database, the next step is to clear the Magento cache. The cache can sometimes contain references to the old admin URL.

You have two options here:

  1. Manually delete the contents of the var/cache directory.

    • Locate your Magento installation’s root directory (usually /path/to/magento/)
    • Navigate to the var/cache subdirectory
    • Delete all files and folders within
  2. Use a cache management script provided by Magento

To use the built-in script:

  1. Open your web browser and navigate to http(s)://<your-domain>/index.php/admin/cache_management/index/key/e8810a39f5e4b3c13d4702318ae65d0b/

    • Replace <your-domain> with your actual domain name
    • You’ll be prompted to log in as an administrator
  2. Select “Flush Magento Cache”

  3. Click the “Submit” button

Step 3: Update the .htaccess File

The .htaccess file is responsible for redirecting requests from the specified admin URL to the Magento root directory. If you’ve changed your admin URL, this file needs to be updated accordingly.

Locate the .htaccess file in your Magento installation’s root directory:

/var/www/html/magento/.htaccess

Open the file in a text editor and look for lines beginning with RewriteRule. These are responsible for the URL rewriting process.

Ensure that the admin URL rewrite rule matches your new configuration. For example, if you’ve set the admin URL to “gestion”, the rule should look like this:

RewriteRule ^gestion/?$ /index.php/admin/ [L]

If the rule doesn’t match or is missing entirely, add it to the end of the file.

In some cases, especially when dealing with extensive customizations, you might need to flush the opcode cache as well. This can help prevent conflicts between old and new versions of cached PHP files.

If your server uses APC or OPcache (which is usually the case), you can flush the cache using a command like this:

sudo service php7-fpm restart

Or, if you’re on an Nginx-FPM setup:

sudo systemctl reload php7-fpm

Step 5: Test Your New Admin URL

With all these steps complete, it’s time to test your new admin URL. Open a web browser and navigate to http(s)://<your-domain>/gestion.

If you’ve followed the steps correctly, you should now be able to access the Magento admin panel using your new URL.

Remember, if you’re still encountering issues, double-check that:

  • There are no typos in your .htaccess rewrite rules
  • The core_config_data table entries match your new settings
  • Your server and PHP configuration support the necessary features (e.g., mod_rewrite must be enabled for URL rewriting)

Conclusion

Changing the Magento admin URL can be a complex process due to the many interconnected components involved. However, with a systematic approach that covers database updates, cache clearing, and file modifications, you should be able to resolve most 404 errors.

If you find yourself still struggling after implementing these steps, don’t hesitate to reach out to Laravel Company for professional Magento development services. Our team of experienced developers is well-equipped to handle even the toughest Magento challenges.

Happy coding!

Cache Database Admin Configuration

Our network