Magento: How to change Admin URL Path?

Here is a quick guide on how to change admin url path in Magento. This need to be done for security reason to be safe from hacking/cracking issue. Basically, this is done not to let any general user to access the admin page.

Generally, we do have ‘admin‘ as the administrator path for Magento. So, the admin URL will be http://www.example.com/admin/

This article will show you, how you can change the admin url. Let’s say from ‘admin‘ to ‘backend‘. So, the new admin URL will be http://www.example.com/backend/.

You can do this from either of the two ways stated below:-

1) Changing local.xml
2) Changing Admin URL from Magento Backend Admin Settings

1) Changing local.xml

– Open app/etc/local.xml
– Find the following:-


<admin>
	<routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[admin]]></frontName>
                </args>
            </adminhtml>
        </routers>
</admin>

– Change <frontName><![CDATA[admin]]></frontName> to your desired name. Like:-
<frontName><![CDATA[backend]]></frontName>

– Save the file
– Refresh the Cache from Magento Admin (System -> Cache Management)

Now, you should be able to access admin panel from http://www.example.com/backend/ instead of http://www.example.com/admin/

2) Changing Admin URL from Magento Backend Admin Settings

The other easy way is to change the admin url from Magento backend setting.

– Go to System -> Configuration -> ADVANCED -> Admin -> Admin Base URL
– Select Use Custom Admin Path as “Yes”
– Add ‘backend‘ in Custom Admin Path field.
– Now you will be logged out.
– Login again and you can see that your admin url has been changed to http://example.com/index.php/backend/

A mistake I made earlier

You can skip this. This is not a necessary step. It is only important, if you have done similar mistake as written below.

I tried to change the Admin Base URL from Magento admin panel but had some problem. Here is what I did:-

– Go to System -> Configuration -> ADVANCED -> Admin -> Admin Base URL
– Select Use Custom Admin URL as “Yes”
– Add ‘backend/‘ in Custom Admin URL field.

While doing so, I had a problem. I could not access the admin path now. My changed admin path should be http://example.com/backend/ or http://example.com/index.php/backend/. But, I was not able to access the path.

The mistake was to change the Custom Admin URL instead of Custom Admin Path.

To solve the problem, I had to make database changes. If you had similar problem then here is a workaround:-

– Open your database
– Browse table ‘core_config_data
– Search in path field for ‘admin/url/custom‘ and set its value to empty
– Search in path field for ‘admin/url/use_custom‘ and set its value to ‘0’
– Here is the SQL query:

UPDATE core_config_data
SET value = ”
WHERE path = ‘admin/url/custom’;

UPDATE core_config_data
SET value = ‘0’
WHERE path = ‘admin/url/use_custom’;

– Search in path field for ‘web/secure/base_url
– You will find two row result. One with scope ‘default’ and another with scope ‘stores’.
– Edit the value of row with scope ‘stores’ with the value of the row with scope ‘default’.

UPDATE core_config_data
SET value = (
SELECT value FROM (
SELECT * FROM core_config_data
) AS ccd
WHERE ccd.path = ‘web/secure/base_url’
AND ccd.scope = ‘default’)
WHERE path = ‘web/secure/base_url’
AND scope = ‘stores’;

– Similarly, repeat the process for ‘web/unsecure/base_url‘:-

– Search in path field for ‘web/unsecure/base_url
– You will find two row result. One with scope ‘default’ and another with scope ‘stores’.
– Edit the value of row with scope ‘stores’ with the value of the row with scope ‘default’.

UPDATE core_config_data
SET value = (
SELECT value FROM (
SELECT * FROM core_config_data
) AS ccd
WHERE ccd.path = ‘web/unsecure/base_url’
AND ccd.scope = ‘default’)
WHERE path = ‘web/unsecure/base_url’
AND scope = ‘stores’;

– Now, you will be able to login to Magento admin with your old admin base URL (http://example.com/index.php/admin).

Hope this helps. Thanks.