Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Magento Custom Admin Backend

You can set your own custom Magento admin URL in:

System -> Configuration -> [ADVANCED] -> Admin -> Admin Base URL

NOTE: Make sure you have added a ServerAlias directive to your virtual host configuration for and that you have a SSL cert or wildcart setup for HTTPS traffic on that subdomain or you will lock yourself out the admin.

Rules for your .htaccess file to prevent duplicate urls and redirect directly to admin dashboard:

    # rewrite main domain /admin to custom admin backend
    RewriteCond %{HTTP:HOST} ^www\.domain\.com$
    RewriteCond %{REQUEST_URI} ^/admin
    Rewriterule (.*) [R=301,L]

    # rewrite any backend domain request that is not /admin to /admin
    RewriteCond %{HTTP:HOST} ^backend\.domain\.com$
    RewriteCond %{HTTP_COOKIE} !^.*adminhtml.*$ [NC]
    RewriteCond %{REQUEST_URI} !/admin/
    RewriteRule .* %{REQUEST_URI}index.php/admin/ [R=301,L]

This comment has been minimized.

Copy link

jorisssss commented Jan 9, 2019

The solution for Magento 2 is pretty simple. Just configure as the main domain name: So the admin will be available at
Change scope to the storeview, and enter as the store domain name. So the store will be available at


This comment has been minimized.

Copy link

thomas-harding commented Mar 19, 2019

Just FYI, the colon in %{HTTP:HOST} doesn't work on some setups. We changed it to %{HTTP_HOST} which worked for us.


This comment has been minimized.

Copy link

MarinaBonbonRose commented May 3, 2019

Hello, there is .htaccess file everywhere, in wich one do you add the new rules ?


This comment has been minimized.

Copy link

rizwan-i-khan commented Jul 26, 2019



This comment has been minimized.

Copy link

ask694 commented Aug 6, 2019

Hi, Is this works for Magento 2 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.