Magento 2 Admin URL: How to set a custom Admin URL

An Admin URL varies with every new platform installation. Once installed, the admin URL and base URL of Magento 2 you get are the following:

Default Base URL:
http://example.com/magento/
Default Admin URL and Path:
http://example.com/magento/admin.

For the sake of security, it is recommended to change the default Magento 2 admin URL to a custom one. It’s highly advised to avoid the default ‘admin’ or the commonly used ‘backend’ names. This will help you avoid determined attackers and reduce exposure to scripts that try to break into Magento websites.

However, you should remember that incorrect URL change can lead to Magento login and backend issues.

Any mistakes made during the Magento 2 change of administration URL in the database and the path change can result in access denial and can be corrected only from the server! Do not try to change the URL unless you know how to edit configuration files on the server! 

Magento 2 Admin URL change

¡Address your hosting provider before changing the default URL, as some hosting services require a standard URL to conform to the firewall protection rules! 

There are two main ways you can set Magento custom Admin URL for your store: 

#1 via the Admin Panel

  • Log in to the Admin Panel, choose Stores>Settings>Configuration;
  • Navigate to the Advanced settings and select Admin;
  • Expand the Admin Base URL section and make the next settings:

admin-path-url-magento

  • In this case, you will have https://example.com/magento2/backend URL. If you want to change only the path, make changes in the Custom Admin Path section and leave the Use Custom Admin URL option set to 'No';

¡The Admin URL must be in the same Magento installation and have the same document root as the frontend of the store!

  • Once it’s made, click the Save Config button and clear the cache.

#2 via the Server Text Manager

  • Open the app/etc/env.php file in a text manager and change the name of the [admin] path. The admin path is located in the app/etc/env.php file. Look for ‘backend’ using the commands: 

    E.g.:

    'backend' => array ( 'frontName' => 'admin')
    or
    'backend' => array ( 'frontName' => ‘backend’)

Don’t forget to use the lowercase characters only and save the changes.

  • Enter to the Admin panel to clear the Magento cache: System> Cache Management> Flush Magento Cache;
  • Return to the server, go to the var/cache folder and delete its content.

To secure your Magento 2 backend from the unauthorized login attempts and log all the backend activities, install our Admin Actions Log extension. Check all logs automatically and get notified of any suspicious activities.

See also: If the custom URL for your Magento store admin is not working correctly and you get a blank page, check this guide to fix the issue.

 

How can we help you?

Didn’t you find the answer to your question? We are always happy to help you out.

© 2009-2024 Amasty. All Rights Reserved.