How to Change the Admin URL in Magento 2?

| |
Comments: 0
How to Change the Admin URL in Magento 2?

Changing the admin URL is one of the most and highly-recommended practices to secure your store from Any types of cyberattacks.To protect your Magento Admin against hackers and brute-force attacks, we recommend that you change the default URL to the Magento Admin Panel. It is a quick way to add an extra layer of security to your site.

Securing your admin panel is an essential task. Magento 2 provides different methods to change the admin URL. Whether you’re a developer or an admin user, you can simplest way to change admin URL.

Recommended Read: How to Create Admin User in Magento 2 Using Command Line?

Use Admin Panel Configuration to Change URL :

This is one of the easiest method to change the admin URL.

  • Log in the Admin panel in your magento 2.
  • Access to the Stores > Setting > Configuration > Advanced > Admin.
  • Open Admin and expand the Admin Base URL section.
  • Select “Use Custom Admin URL” to “Yes”.
  • You can Enter the custom admin URL
  • Also, you can enable the “Use Custom Admin Path” field and just set the custom admin path instead of the entire URL. This is an alternate method.
  • You will be logged out and redirected to the new Admin URL.

Use env.php File To Change Admin URL :

  • Open to app/etc/env.php file in a text editor.
  • Search for the ‘frontName’ parameter that could be something like ‘admin’ or ‘backend’.
  • Replace it with your custom admin panel path.
  • Select “Use Custom Admin URL” to “Yes”.
  • You can Enter the custom admin URL
  • Also, you can enable the “Use Custom Admin Path” field and just set the custom admin path instead of the entire URL. This is an alternate method.
  • You will be logged out and redirected to the new Admin URL.
‘backend’ => [
‘frontName’ => ‘rock_admin’
]

Change Admin URL via Command Line :

  • Log in to your Magento server via SSH. Navigate to the root directory of your store.
  • Run following command in your magento root directory:
  • Within the quotes for backend front name – type in your desired new URL.
  • If you would like to check or view your admin URL via following command line:

Conclusion :

We hope above blog helps you to clearly understand “How to change the admin URL in Magento 2”. In case of any kind of problem with the above code implementation, you can contact us or let us know in comment section.

Learn more: 6 Product Types in Magento 2 Explained

Also Learn: How to Create Custom Page in Magento 2?

Also Learn: How to Create Custom API and Customer in Magento 2?

Leave a Reply

Your email address will not be published. Required fields are marked *