1

Today i had tried to use the sub domain like admin.domain.com for admin panel by setting the custom url for admin panel in system -> config -> Advanced -> admin -> admin base url -> Custom Admin URL

After changing the url with sub domain. Unable to login admin panel by sub domain. I'm getting too many redirect error. sometimes it going to base domain like www.domain.com. Even after clearing the cache problem still not solved. Anyone help me Regarding this issue, that will be highly appreciated.

Note: I had already tried the solutions on the similar post but nothing will work. And i'm using magento 2.2.6

  • you need to create separate virtual host for admin.domain.com , do you have one? – MagenX Aug 6 at 20:14
  • yes, i have created a sub domain pointing the magento root folder. virtual host means sub domain right? – Ask Bytes Aug 7 at 6:47
  • which redirect loop you have then? – MagenX Aug 7 at 8:23
  • if i hit sub domain the url path changed to subdomain.domain.com/admin and again it changed to www.domain.com/admin – Ask Bytes Aug 7 at 8:39
  • you probably have many issues, bug - https://github.com/magento/magento2/issues/12354 or rewrite rule in server config. – MagenX Aug 7 at 9:09
0

Usually, when you want a separate Admin Base URL it also means you need an admin instance (which separate with your webserver stacks), and in that case, I suggest you do the following approach:

  • Set your admin URLs as the global (Default store view) config in Config > General > Web (for e.g: admin.example.com)
  • Set your other store URLs in the corresponding Website configurations (e.g US, UK...etc)
  • Check and change the Cookie domain for admin URL instance (Global one) to your wanted sub-domain.
  • Find and fix all issues related to admin base URLs (Magento 2 acknowledge for e.g WYSIWYG media URL)

Magento 2 has the functionality to use separate Admin URL, but unfortunately, based on my own experience it won't help :(

Cheers,

  • I agree with this. Admin as separate website on it's entirely own domain may be safest route to go – Dominic Xigen Aug 19 at 12:19
  • There is an issue on Magento2 for custom admin URL – Ask Bytes Aug 20 at 11:41
  • @AskBytes this is not the custom admin url – Toan Nguyen Aug 20 at 11:45
0

From your question, I am assuming you have set all configurations.
But you haven't set the .htaccess redirection,
Try to set the 301 .htaccess redirection as below.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^admin\.example\.com$
RewriteCond %{REQUEST_URI} !/admin
RewriteRule %{REQUEST_URI}/admin/ [R=301,L]
  • It is giving ERR_TOO_MANY_REDIRECTS error. – Ask Bytes Aug 20 at 11:28
  • whats your subdomain? – Rizwan Khan Aug 20 at 12:04
  • admin.domain.com is subdomain – Ask Bytes Aug 20 at 13:22
0

You can set your own custom Magento admin URL in:

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

Use Custom Admin URL = (YES) Custom Admin URL = https://backend.domain.com

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 (.*) https://backend.domain.com [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]
  • It is giving ERR_TOO_MANY_REDIRECTS error. – Ask Bytes Aug 20 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.