How To Change Admin URL In Magento 2
In this post, I will guide you on How To Change Admin URL In Magento 2. For security reasons, Magento recommends that store owners apply many methods to increase the security of their stores, avoiding the eyes of hackers. Changing the admin path is an effective security way to prevent hackers from accessing your store admin panel – a very important place, containing a lot of important information about your customers and your store.
Change Admin URL In Magento 2
Use Admin Panel
1. Log in to Admin Panel.
2. On the Admin Panel sidebar, go to Stores > Settings > Configuration.
3. In the left panel, choose ADVANCED > Admin.
4. Expand the Admin Base URL section.
5. Untick Use system value and set Use Custom Admin URL and Use Custom Admin Path to “Yes”.
6. Enter your Custom Admin URL and Custom Admin Path.
For example:
Custom Admin URL is: https://yourdomain.com/magento2/
Custom Admin Path is: admin
Note: Make sure that your Custom Admin URL ends with ‘/’ (slash). |
7. Click Save Config when complete.
Run Magento 2 CLI
1. First, you need to connect to your server via SSH as the root user by command:
ssh root@<your-ip-address> -p <your-port-number>
2. Go to Magento 2 root folder.
3. Run the command below to change admin path:
php bin/magento setup:config:set --backend-frontname="your_admin_path"
Edit env.php
- Open env.php file in the following path:
app/etc/env.php
2. Navigate to the backend and check the “frontName” property. You can see it in env.php file like this:
'backend' => [
'frontName' => 'admin'
],
3. Change the value of ‘frontName’ parameter to admin_path you want.
Ex: We change ‘admin’ to ‘your_admin_path’. You can see the backend will look like this
'backend' => [
'frontName' => 'your_admin_path'
],
4. Run flush cache command:
php bin/magento cache:flush
Follow us for the more helpful posts!
We hope this is a useful post for you.
You can read more useful posts like How To Change Default Admin Logo In Magento 2.
Thank you for reading!