Updated on Mar 13, 2019
Magento 2 has the option for you to type a custom Admin URL when you install it, but if you wish to later change your Admin URL again, you might find the option for it in the admin dashboard and as a result make your admin area inaccessible.
To correctly change the admin URL of your Magento 2 website, you will need to first go into cPanel → FIle manager and find the file env.php located in:
/public_html/app/etc/
Right click on the file and select the Edit Code option.
Now you will need to change this line:
'frontName' => 'admin'
By adding your new admin URL in the 'admin' field.
Click on the Save Changes button at the top right corner and you are done with the file change.
Now you will also need to modify a line in one of the tables of your Magento 2 database. You can do that, by navigating to the phpMyAdmin service located in your cPanel.
Click on the Database you use for the Magento 2 application and open the core_config_data table. Now look for the entry:
admin/url/custom
which will most likely be on page 11.
You will need to change the /admin part in http://yourdomain/admin to the same value you added in the env.php file by clicking on the Edit button for this entry.
When you are ready, click on the Go button to apply the change.
Congratulations, you have successfully changed the Admin URL for your Magento 2 Store.