In Magento 2, you can set the admin custom URL via the command line interface (CLI) using the bin/magento
command. This can be useful for security purposes by changing the default /admin
URL to something custom to make it harder for potential attackers to find your admin panel. Here are the steps to set the admin custom URL via CLI:
-
Access Your Server via SSH:
Connect to your server via SSH using your terminal or an SSH client. -
Navigate to Your Magento 2 Root Directory:
Use thecd
command to navigate to your Magento 2 installation directory:cd /path/to/your/magento2
-
Set the Custom Admin URL:
Use thebin/magento
command to set the custom admin URL. Replacewith the custom URL you want to set:
bin/magento setup:config:set --backend-frontname=<your_custom_url>
For example, if you want to set the custom admin URL to “myadmin,” you would run:
bin/magento setup:config:set --backend-frontname=myadmin
-
Clear the Configuration Cache:
After setting the custom admin URL, clear the configuration cache to apply the changes:bin/magento cache:clean config
-
Verify the Custom Admin URL:
After completing the above steps, you can access the Magento admin panel using the custom URL you specified. For example, if you set the custom URL to “myadmin,” you can access the admin panel athttp://yourdomain.com/myadmin
.
Please note that it’s essential to remember your custom admin URL as you’ll need it to access the admin panel in the future. Also, be cautious when changing the admin URL, and make sure you choose a unique and secure custom URL to protect your Magento store from unauthorized access.
Comments