Magento – Redirect Admin server homepage to admin login page by default

adminmagento-1.7nginxredirect

I have separated our magento setup into load balanced frontend servers and a single admin backend server. I have specified : web/url/redirect_to_base = 0
and have setup the custom admin url in database.

The access to magento admin panel works fine at http://admin.magento.com/customadminpath but the homepage url http://admin.magento.com/ now shows the webstore frontend which is not what I wanted.

How can I redirect any requests for homepage on admin server to the admin url with admin path?

I have tried putting rewrites in nginx but couldn't get it to work. What I'm trying to setup here is any requests to admin.magento.com should be redirected to admin.magento.com/customadminpath so that no one can access the frontend pages on admin.magento.com.

Also, what's the correct approach for this, through nginx configuration or change in the index script?

Best Answer

Use .htaccess to set up the 301 redirect for you:

Setting up a permanent 301 redirect via .htaccess

Edit: Alternatively for nginx:

What is nginx equalant for my htaccess mod_rewrite?