2

I have a store set on a different domain to my main magento installation. I then have stores in sub-folders using the second domain e.g.

  • maininstall.com
  • aliasdomain.com
  • aliasdomain.com/store1
  • aliasdomain.com/store2

etc...

Now I added the nginx code to get my aliasdomain working in the root in my .conf

map $http_host $MAGE_RUN_CODE {
    aliasdomain.com viewcode;
    www.aliasdomain.com viewcode;
}
....
 location ~ \.php$ { ## Execute PHP scripts
...
        fastcgi_param  MAGE_RUN_TYPE store;
        fastcgi_param  MAGE_RUN_CODE $MAGE_RUN_CODE;
...
    }

The aliasdomain.com works fine however the subfolders do not. Basically upon opening one in browser it all works fine, but clicking onto ANY page / product in that store causes a redirect back to "aliasdomain.com" with no subfolder.

I have not added nginx configuration for these stores as there is no need they all have their own index.php with the following in:

$mageRunCode = 'viewcode2';
$mageRunType = 'store';

Mage::run($mageRunCode, $mageRunType);

Does anyone know what could be causing this behaviour? I am stumped! This worked fine on Apache and I have just moved to nginx but can't see why the homepage would load (the store code is working) but then subsequent pages don't.

I have "Auto Redirect to BASE URL" set to Yes (302) in the backend (which was working fine on Apache) and if I turn it off the pages load the correct url e.g. aliasdomain.com/store1/page1 but I get a 404. Thought that was worth noting!

Thanks in advance!

EDIT:

I just found going into the store backend and setting "Use webserver rewrites > No" fixes the issue.

The problem is I am sure I need this ticked to yes, does this narrow down where my problem lies?

Thanks!

0

Besides index.php, the subdirectories also need their own .htaccess (or their own rewrite configuration in nginx).

Otherwise all URLs that are not pointing to a file (i.e. index.php), are handled by the rewrite rule of the default store.

Then for example

/store1/customer/account/login

translates to

/index.php/store1/customer/account/login

and since there is no controller for the "store1" frontend name you get redirected to the home page.

What you need is:

/store1/index.php/customer/account/login

Related topic with more details: Store code in URL for every store view except for default

0

Ok I managed to figure this out, the .htaccess changes made no difference and I was stuck! I managed to figure out turning off URL rewrites for the store fixed the redirect but left /index.php/ in the URLS.

Then when looking at ways to fix this in NGINX I found some code used on wordpress in the nginx configuration which I used and it worked!

location /subfolder/ { index index.php index.html index.htm; try_files $uri $uri/ /subfolder/index.php?$args; }

This allows me to keep on rewrites in the backend and also stops the homepage redirect!

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.