- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
multi-wesbsite admin url not working
I have a 2 website under different domains
1. domain1
2. domain2
both websites working through nginx:443 with routing to nginx:80
server { listen 80; listen [::]:80; server_name domain1; set $MAGE_ROOT /opt/domain1/current; set $MAGE_RUN_TYPE "website"; set $MAGE_RUN_CODE "domain1"; include /opt/domain1/current/nginx.conf; }
server { listen 80; listen [::]:80; server_name domain2; set $MAGE_ROOT /opt/domain1/current; set $MAGE_RUN_TYPE "website"; set $MAGE_RUN_CODE "domain2"; include /opt/domain1/current/nginx.conf; }
in a scope of website2 with domain2 admin not working
is it expectable? or what I'm doing wrong
domain1/admin - works
domain2/admin - doesn't work
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: multi-wesbsite admin url not working
It is expected. It's scoping thing. Your administration's base URL is what is set on scope 0. There can only be one value in scope 0.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: multi-wesbsite admin url not working
Hello @svecom360ca5d7,
The issue with domain2/admin not working in your multi-website Magento setup is related to how Magento handles the base_url and the admin URL routing. By default, Magento uses the base_url defined in the Default Config for the admin panel, and it is not scoped to individual websites. Therefore, only domain1/admin works because domain1 is the base URL in the default configuration.
To make the admin panel accessible on domain2, you need to adjust the configuration and ensure proper routing:
Magento does not support having multiple admin URLs natively. The admin URL will always use the base_url defined in the Default Config.
If you want to access the admin panel from both domain1 and domain2
Enable routing of the admin panel through domain2 using additional configuration.
Allow Admin on Both Domains
If you must access the admin panel on both domains, you'll need to force Magento to recognize the admin URL for both domain1 and domain2.
Steps:
Update env.php: Open app/etc/env.php and add the following configuration:
'web' => [ 'admin' => [ 'url' => 'relative', // Allows admin to work on both domains ], ],
Configure Nginx: Ensure both domains route to the same Magento installation, as you already have:
server { listen 80; server_name domain1; set $MAGE_ROOT /opt/domain1/current; set $MAGE_RUN_TYPE "website"; set $MAGE_RUN_CODE "domain1"; include /opt/domain1/current/nginx.conf; } server { listen 80; server_name domain2; set $MAGE_ROOT /opt/domain1/current; set $MAGE_RUN_TYPE "website"; set $MAGE_RUN_CODE "domain2"; include /opt/domain1/current/nginx.conf; }
Set Admin URL in Both Domains:
- In Magento's backend (Stores > Configuration > General > Web), ensure:
- Base URL is set for each domain.
- Use Secure URLs in Admin is enabled.
If you allow admin access on both domains, you can access the admin panel on both domain1/admin and domain2/admin.
If the issue will be resolved, Click Kudos & Accept as a Solution.