I created a multi stores magento setup on 2 subdomains:
- domain1.example.com (contains magento 2 files)
- domain2.example.com (alias)
I aliased the domain2 to domain1 and redirect to the correct store based on domain name in the index.php on domain1 as done here.
I setup the correct BaseURLS and everything seems to work.
When I was testing a product and added the product to the 2nd store it would show everything except for the image.
On closer inspection the 2nd store cannot seem to find (404 errors) anything in the /pub/media folder (this includes styles.css and the images in the customer folder):
Everything in the /pub/static will load fine!
I did some more testing and basically it's based on the filetype:
I uploaded some test files:
- domain1.example.com/pub/media/test.txt -> works
domain2.example.com/pub/media/test.txt -> works
domain1.example.com/pub/media/test.png -> works
domain2.example.com/pub/media/test.png -> NOT WORKING: 404-error
domain1.example.com/pub/media/test.css -> works
- domain2.example.com/pub/media/test.css -> NOT WORKING: 404-error
So it seems something goes wrong with rewriting, but I cannot seem to find the source.
I tried deploying, resfreshing and recaching etc. Tried changing permissions (but shouldn't make difference if other filetypes DO work). Tried deleting the .htaccess, no difference.
Been trying to figure it our for almost a day now, any help would be greatly appreciated!
UPDATE: Using the first domains MEDIA folder in the Store configuration fixes the issue!