0

Nginx & Magento CE 1.9.0.1

I created an additional store in a sub-directory (e.g. shoes.com/sneakers/). Every link in the main site - shoes.com - works. If I try to visit a CMS page of the shoes.com/sneakers/ site (e.g. privacy), I get a 404 from the main site - shoes.com. If I precede the URL of the CMS with index.php so that the entire URL looks something like shoes.com/sneakers/index.php/privacy it works however the Nginx configuration I'm using now is using and hiding the index.php in the URL for anything at shoes.com.

Is it possible that sub-directories are excluded from this directive or that through misconfiguration, it only applies to the main site?

Additional Information: I followed Magento's documentation to create a secondary store - copying index.php and .htacccess over, changing the $mageRunCode in index.php and creating symbolic links for the necessary folders. This is working locally on my MAMP environment but not on staging. I checked permissions and still no luck. It's loading Magento, the correct package but not the correct theme which I have double-checked in the admin panel.

2
  • 1
    So you put a full new installation in a subdirectory? Any specific reason not to use the multi site feature of Magento? In either case, your nginx configuration is not correct, what do you have now? Commented Aug 28, 2014 at 6:20
  • I am in fact using Magento's documented method of multistore setup however this appears to be strictly a server rewrite issue. Nginx isn't including the index.php in shoes.com/sneakers/index.php/checkout/cart for example. When I realized this I opened a thread in Server Fault. Here is the link which includes my rewrite config: serverfault.com/questions/624732/… Commented Aug 28, 2014 at 14:34

1 Answer 1

1

You need to put an index.php in the subdirectory, otherwise Magento handles the URL as part of the request URL instead of the store root. In the index.php you need to change the following line:

$mageFilename = MAGENTO_ROOT . '/app/Mage.php';

to

$mageFilename = MAGENTO_ROOT . '../app/Mage.php';

in order to load the Magento installation.

7
  • My symbolic links point Magento to those system folders. I followed Magento's documentation for creating a separate store. It works on my local MAMP environment but not in my LEMP staging environment. Already checked permissions. Commented Aug 28, 2014 at 13:19
  • I prefer not to use symlinks but to only have an index.php file that points to the correct Mage.php. In your store URL configuration you have to make sure that the URL used is correct (for example the media URL would then be: example.com/media instead of example.com/secondstore/media) Commented Aug 28, 2014 at 13:22
  • Interesting. So you're saying I can run this additional store in a sub-directory by only including an index.php in "sneakers" for example? No other files necessary if the mage.php path is defined to be above it? Commented Aug 28, 2014 at 13:24
  • 1
    Just copy the index.php file and change the line I described above (and if you use the compiler the line with the path to the includes directory) and you should be able to run. I used this several times on multistore installations where I needed a clean home directory per website to allow (s)FTP uploads per client without full access to Magento. Commented Aug 28, 2014 at 13:28
  • 1
    Yes, I do not use the base url to build the media/js/skin url but use the URL without the store name in it. Commented Aug 28, 2014 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.