Magento change complete admin url

Magento change complete admin url

August 20, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento change complete admin url

Changing Your Magento Admin URL: A Comprehensive Guide

As a Magento developer, you might find yourself needing to change your admin URL for security reasons or simply to organize your website structure more efficiently. However, the process requires careful handling to ensure your frontend remains accessible while protecting your backend.

Understanding the Current Set-up

In a typical Magento installation, the admin URL is set as www.domain.com/admin. This is defined in the core config file located at app/etc/config.xml.

The current set-up allows for easy access to the admin panel via a subdirectory of the main domain. However, this also means that anyone who knows your domain can potentially guess your admin URL.

The Desired Configuration

You want to switch your admin access to www.newdomain.com/admin, while keeping your frontend accessible on the old domain (www.domain.com).

This requires two key changes:

  1. Redirecting all admin requests from the old domain to the new one.
  2. Maintaining the original frontend URL for customer access.

Changing the Admin URL

To change the admin URL, we’ll modify the core config file directly. This is a manual process that should be done with extreme caution as it involves editing core files—always make sure you have a backup of your site before proceeding.

  1. Navigate to app/etc/config.xml.

  2. Locate the <admin> section under <global>. It should look something like this:

<admin>
    <routers>
        <adminhtml>
            <args>
                <frontName><![CDATA[admin]]></frontName>
            </args>
        </adminhtml>
    </routers>
</admin>
  1. Update the frontName value to match your new admin URL, without the /admin suffix:
<admin>
    <routers>
        <newadmin> <!-- Replace 'newadmin' with your desired prefix -->
            <args>
                <frontName><![CDATA[admin]]></frontName>
            </args>
        </newadmin>
    </routers>
</admin>
  1. Save the file and clear your cache: rm -rf var/cache/*.

Redirecting Admin Requests

To redirect admin requests to the new domain, you’ll need to modify your .htaccess file in the Magento root directory.

  1. Open the .htaccess file.

  2. Add the following rewrite rule at the end of the file:

RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^admin/.*$ https://newdomain.com/admin/$1 [R=301,L]

Replace domain.com with your old domain and https://newdomain.com/ with your new admin URL.

Maintaining the Frontend URL

Your frontend remains unchanged because Magento uses the base_url configuration defined in app/etc/local.xml. This setting determines where to serve the static files from, not the URL that customers type into their browsers.

By default, this is set as follows:

<![CDATA[https://domain.com/]]>

You don’t need to change this for your frontend to remain accessible at www.domain.com.

Conclusion

Changing the Magento admin URL involves a combination of editing core configuration files and adding rewrite rules to handle redirections. Remember, these are delicate operations requiring careful handling.

Always ensure you have a backup before making changes, and thoroughly test your setup after each modification to avoid potential downtime or security vulnerabilities.

For more advanced techniques on Magento customization, consider exploring the resources available at Laravel Company. They offer in-depth guides for developers looking to master Magento development.

Security Admin Configuration Customers

Our network