How to Change the Magento Admin URL
The Magento Admin URL is the address used to access the backend of a Magento store. By default, some Magento installations may use a predictable administrator path, while others are configured with a custom path during installation.
Changing the Magento Admin URL can make the administrative endpoint less predictable and can be useful as one layer of a broader security strategy. However, changing the URL should not be considered a replacement for strong passwords, two-factor authentication, access controls, security updates, and other Magento security practices.
In Magento, the Admin URL is controlled through the frontName value in the Magento environment configuration.
This guide explains how to change the Magento Admin URL safely using SSH, DirectAdmin, cPanel, or a file editor.
What Is the Magento Admin URL?
The Magento Admin URL is the backend address where administrators sign in and manage the store.
For example:
https://example.com/admin
A customized Admin URL might look like:
https://example.com/storemanager
or:
https://example.com/admin_7x9k
The exact path depends on your Magento configuration.
Why Change the Magento Admin URL?
A customized administrator path can make the backend URL less obvious to automated scanners that target common administrator paths.
For example, instead of:
https://example.com/admin
you could use:
https://example.com/controlpanel
However, the URL itself should not be treated as a complete security mechanism.
A secure Magento installation should also use:
- HTTPS
- Strong administrator passwords
- Two-factor authentication
- Role-based permissions
- Regular Magento updates
- Updated extensions
- Server-level access controls
- Security monitoring
- Reliable backups
Before Changing the Magento Admin URL
Changing the administrator path affects how you access the Magento backend, so prepare the server before making the change.
1. Create a Backup
Create a current backup of your Magento files and database.
At minimum, make sure you can restore:
app/etc/env.php
and your Magento database.
2. Make Sure You Have SSH or File Access
You need access to the Magento installation directory.
Depending on your hosting environment, this may be through:
- SSH
- DirectAdmin File Manager
- cPanel File Manager
- Another server management panel
3. Record the Current Admin URL
Before making changes, note the existing administrator URL.
For example:
https://example.com/admin
This makes troubleshooting easier if the new URL does not work.
Where Magento Stores the Admin URL
Magento stores the administrator front name in:
app/etc/env.php
Inside this file, look for the backend section.
A configuration may look similar to:
'backend' => [
'frontName' => 'admin'
],
The value of:
frontName
determines the administrator path.
For example:
'frontName' => 'storeadmin'
means that the Admin URL uses:
https://example.com/storeadmin
How to Change the Magento Admin URL Using SSH
SSH is one of the most direct ways to change the Magento administrator path.
Step 1: Connect to Your Server
Connect to the server using SSH:
ssh username@server-ip
Replace:
username
with your server username and:
server-ip
with your server’s IP address or hostname.
Step 2: Navigate to the Magento Directory
Change to your Magento installation directory.
For example:
cd /var/www/html
Your actual Magento path may be different.
You can verify that you are in the correct directory with:
ls
A Magento root directory commonly contains:
app
bin
composer.json
pub
vendor
var
Step 3: Back Up env.php
Before modifying the configuration, create a backup:
cp app/etc/env.php app/etc/env.php.backup
This gives you a quick way to restore the previous configuration if necessary.
Step 4: Open env.php
Use an editor such as nano:
nano app/etc/env.php
Find:
'backend' => [
'frontName' => 'admin'
],
Change admin to your desired administrator path.
For example:
'backend' => [
'frontName' => 'storemanager'
],
Save the file.
If using nano:
Ctrl + O
Enter
Ctrl + X
Step 5: Flush Magento Cache
After changing the configuration, clear the Magento cache:
php bin/magento cache:flush
You can also check the cache status:
php bin/magento cache:status
Step 6: Test the New Admin URL
Open your new administrator URL:
https://example.com/storemanager
Replace example.com with your domain.
If the login page appears, enter your existing administrator credentials.
Step 7: Test the Storefront
After changing the Admin URL, also test the customer-facing website:
https://example.com
Check:
- Homepage
- Product pages
- Category pages
- Customer login
- Cart
- Checkout
- Admin login
Changing the administrator path should not normally change the storefront URL.
Change Magento Admin URL With a One-Line Command
For experienced administrators, the Magento CLI can be used to configure the backend front name.
From the Magento root directory, you can use:
php bin/magento setup:config:set --backend-frontname="storemanager"
Then flush the cache:
php bin/magento cache:flush
Afterward, access:
https://example.com/storemanager
Important
Always verify the command against the Magento version and deployment environment you are running before using it on a production store. If you use a custom deployment or configuration management system, make sure the change is also reflected in your deployment process.
How to Change Magento Admin URL on DirectAdmin
If Magento is hosted on DirectAdmin, you can change the Admin URL through SSH or File Manager.
Method 1: Using DirectAdmin File Manager
Step 1: Log in to DirectAdmin
Open your DirectAdmin account.
Step 2: Open File Manager
Navigate to your Magento installation.
A common location is:
domains/example.com/public_html
Step 3: Open env.php
Navigate to:
app/etc/env.php
Step 4: Find frontName
Look for:
'backend' => [
'frontName' => 'admin'
],
Change it to:
'backend' => [
'frontName' => 'storemanager'
],
Step 5: Save the File
Save the changes.
Step 6: Flush Magento Cache
If SSH access is available:
cd ~/domains/example.com/public_html
php bin/magento cache:flush
Then test:
https://example.com/storemanager
Change Magento Admin URL on cPanel
You can also change the administrator path through cPanel’s File Manager.
Step 1: Open File Manager
Log in to cPanel and open File Manager.
Navigate to the Magento installation.
For example:
public_html/
Step 2: Open env.php
Navigate to:
app/etc/env.php
Step 3: Locate the Backend Configuration
Find:
'backend' => [
'frontName' => 'admin'
],
Change the path:
'backend' => [
'frontName' => 'storemanager'
],
Step 4: Save the File
Save the configuration.
Step 5: Clear Magento Cache
If you have terminal or SSH access:
php bin/magento cache:flush
Then open:
https://example.com/storemanager
How to Choose a New Magento Admin URL
Choose an administrator path that is:
- Not obvious
- Easy for authorized administrators to remember
- Not identical to the domain name
- Not unnecessarily long
- Compatible with your access policies
For example:
storemanager
is easier to remember than an extremely complicated random string.
You could also use a less predictable path such as:
admin_84kx
Avoid paths containing sensitive information such as:
companypassword
or:
secretadmin
The purpose is to make the endpoint less predictable, not to store a secret in the URL.
What Happens to the Old Admin URL?
After changing:
frontName
the old administrator path should no longer be the correct Magento Admin URL.
For example, if you changed:
/admin
to:
/storemanager
you should use:
https://example.com/storemanager
for future administrator logins.
Do not assume that Magento will automatically redirect the old URL to the new one.
What If the New Admin URL Does Not Work?
If the new URL returns an error, check the following.
1. Verify frontName
Run:
grep -n "frontName" app/etc/env.php
Make sure the configured value matches the URL you are using.
For example:
'frontName' => 'storemanager',
means:
https://example.com/storemanager
2. Check for Typographical Errors
Make sure the URL matches the configuration exactly.
For example:
storemanager
is different from:
store-manager
and:
storeManager
3. Flush the Cache
Run:
php bin/magento cache:flush
4. Check Magento Logs
Review:
var/log/
You can use:
tail -f var/log/system.log
and:
tail -f var/log/exception.log
when troubleshooting.
5. Check Web Server Logs
If Magento logs do not reveal the problem, check the Apache or Nginx error logs.
A web-server configuration problem can prevent the new Admin URL from reaching Magento correctly.
What If You Completely Lose Access to the Magento Admin?
If you accidentally configure the wrong administrator path, you can restore the previous value directly in:
app/etc/env.php
For example:
'backend' => [
'frontName' => 'admin'
],
Then clear the cache:
php bin/magento cache:flush
Afterward, test the original administrator URL.
This is why creating a backup before changing env.php is recommended.
Common Mistakes When Changing the Magento Admin URL
Mistake 1: Editing the Wrong Magento Installation
On servers hosting multiple websites, make sure you modify the env.php belonging to the correct Magento installation.
Mistake 2: Forgetting the New URL
After changing the administrator path, save the new URL in your password manager or internal documentation.
Mistake 3: Not Clearing Cache
Magento configuration changes may not behave as expected until the appropriate cache is refreshed.
Mistake 4: Sharing env.php
Never publicly share the complete contents of:
app/etc/env.php
It contains sensitive configuration information.
Mistake 5: Treating a Hidden Admin URL as Complete Security
Changing the URL does not replace proper authentication or security controls.
Mistake 6: Changing Production Configuration Without a Backup
Always maintain a recovery path before making configuration changes on a live store.
Does Changing the Admin URL Improve Magento Security?
A non-default or less predictable Admin URL can reduce exposure to automated requests targeting commonly known administrator paths.
However, it should be considered a defense-in-depth measure, not a primary security control.
For stronger Magento security, combine it with:
- HTTPS
- Strong passwords
- Two-factor authentication
- Least-privilege administrator roles
- Regular security updates
- Updated extensions
- Server firewalls
- Access restrictions
- Security monitoring
- Regular backups
Recommended Magento Admin Security Setup
A practical administrator security setup can include:
| Security Measure | Purpose |
|---|---|
| Custom Admin URL | Makes the endpoint less predictable |
| HTTPS | Encrypts administrator traffic |
| Strong password | Protects administrator credentials |
| 2FA | Adds another authentication factor |
| Admin roles | Limits user permissions |
| IP restrictions | Limits where administrators can connect |
| Firewall/WAF | Filters unwanted traffic |
| Updates | Addresses known security issues |
| Backups | Provides recovery capability |
| Monitoring | Helps identify suspicious activity |
No single measure should be relied upon by itself.
Frequently Asked Questions
Can I change the Magento Admin URL?
Yes. Magento’s administrator path is controlled by the backend frontName configuration in:
app/etc/env.php
It can also be configured through Magento’s CLI tools.
What file contains the Magento Admin URL?
The administrator front name is stored in:
app/etc/env.php
Look for:
'backend' => [
'frontName' => '...'
],
Do I need to change my Magento administrator username?
No. Changing the Admin URL does not require changing the administrator username.
Will changing the Admin URL affect my customers?
Normally, changing the backend path does not change the public storefront URL. However, you should always test both the storefront and backend after making the change.
Do I need to restart Apache or Nginx?
Usually, changing the Magento backend front name does not require a web-server restart. Clear the Magento cache and test the new URL. If your server uses additional caching or custom configuration, follow your deployment procedures.
Can I use any word as the Admin URL?
The path should follow Magento’s configuration requirements and should not conflict with another application route or server configuration. Choose a simple, non-obvious path that your administrators can manage safely.
Is changing the Admin URL enough to secure Magento?
No. It is only one layer of defense. Strong authentication, two-factor authentication, updates, least-privilege access, server security, monitoring, and backups remain important.
Quick Checklist
Before finishing the change, verify:
- Magento backup is available.
app/etc/env.phphas been backed up.- The correct Magento installation was selected.
- The
frontNamevalue was changed correctly. - Magento cache was flushed.
- The new Admin URL opens successfully.
- Administrator login works.
- The storefront still works.
- Magento logs show no new errors.
- The new Admin URL has been stored securely.
- Two-factor authentication is enabled where appropriate.
Final Thoughts
Changing the Magento Admin URL is a relatively simple configuration task, but it should be performed carefully on a production store. The key configuration is the backend.frontName value in app/etc/env.php, which determines the path used to access the Magento backend.
Before making the change, create a backup and record the existing configuration. Afterward, clear the Magento cache and test both the new administrator URL and the customer-facing storefront.
Most importantly, treat a custom Admin URL as an additional security layer rather than a replacement for strong authentication, two-factor authentication, regular updates, access controls, monitoring, and backups.
If you want, the next related Magento article can be “How to Create Magento Admin Users and Roles” to continue the administration/security series.