I have a feeling that you may be taking the wrong approach... there is
no need to use these subfolders for each storefront any more.
Each separate storefront has an unique type / code pair, which needs to
be passed to Magento to identify the site you're using. I find the
simplest way to set it up is to map a couple of variables:
Here's a completely untested example which should ensure that the right
storefront is used... nothing else necessary
map $request_uri $mage_type {
default store;
~^/site1 website;
~^/site2 website;
}
map $request_uri $mage_code {
default default;
~^/site1 site1;
~^/site2 site2;
}
And then your php block would be...
location ~ \.php$ {
add_header X-UA-Compatible 'IE=Edge,chrome=1';
try_files $uri =404; expires off;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
fastcgi_param SERVER_PORT 80;
fastcgi_param HTTPS $fastcgi_https;
fastcgi_param MAGE_RUN_CODE $mage_code;
fastcgi_param MAGE_RUN_TYPE $mage_type;
}
On 14/07/15 10:03, J_12 wrote:
> There is a website that has multiple subcatogories which are stores in
> magento:
>
> www.website.com/sub1 www.website.com/sub2 www.website.com/sub3
>
> The server used is ngnix. everything is set up. And used to work, the nginx
> conf file for this site need to be reconstructed.
>
> at the moment when for example www.website.com/sub1 is requested this wil
> set the store to store to sub1. which works fine. However when a product is
> asked i.e. www.website.com/sub1/product this returned a "page not found"
> error.
>
> If the store is set to sub1 the url www.website.com/product DOES FIND the
> product without any issues. on the other hand f the store was not set
> previously, www.website.com/product DID NOT FIND the product.
>
> it seemed that once a store is set the following happens e.g.
> www.website.com/sub1/product :
>
> sub1->sub1->product == error (because of sub1->sub1)
>
> this should be:
>
> sub1->product.
>
> note that setting the store when www.website.com/sub1/product is requested
> and then redirecting the site to www.website.com/product is not an option.
> everything used to work fine! The store setup had not been changed. only the
> the nginx conf file should be adjusted. any sugestions?
>
> to be more specific: in the root folder there is an index.php file were
> magento is set to run the website via mage run code. In the root folder
> there are subfolders one for each store. these folders each contain an
> index.php file were the store is set. any more info needed?
>
> Any help would be appreciated.
>
> additional info: in the root folder there is an index.php file were magento
> is set to run the website via mage run code. In the root folder there are
> subfolders: one for each store. These folders each contain an index.php file
> were the store is set( again via mage run code) (the stores are being set
> correctly in these files).
>
> the nginx conf looked like this:
>
>
>
>
> server {
>
> listen 80 default;
> server_name website.com;
> root /www_folder;
> client_max_body_size 10M;
>
> location / {
> index index.php;
> try_files $uri $uri/ @handler;
> expires 30d;
> }
>
>
> location /mage/ {
> try_files $uri $uri/ @magehandler;
> expires 30d;
> }
>
> location @handler {
> ## Remove trailing slash
> rewrite ^/(.*)/$ /$1 permanent;
> ## Magento uses a common front handler
> rewrite / /index.php;
> }
>
> location @magehandler {
> ## Adds a trailing slash to any urls that is missing a trailing slash
> rewrite ^(.*[^/])$ $1/ permanent;
> ## Magento uses a common front handler
> rewrite /mage/ /mage/index.php;
> }
>
>
> ## These locations would be hidden by .htaccess normally, protected
> location ~
> (/mage/(app/|includes/|lib/|pkginfo/|var/|errors/local.xml|shell/|tmp/|cron.+)|/\.git/|/\.ht.+)
> {deny all;}
>
> location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
> expires max;
> log_not_found off;
> }
>
> location /. { ## Disable .htaccess and other hidden files
> return 404;
> }
>
> location ~ .php/ {
> rewrite ^(.*.php)/ $1 last;
> }
>
> location ~ \.php$ {
> add_header X-UA-Compatible 'IE=Edge,chrome=1';
> try_files $uri =404;
> expires off;
> fastcgi_index index.php;
> fastcgi_pass unix:/var/run/php5-fpm.sock;
> #fastcgi_pass 127.0.0.1:9000;
> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
> include /etc/nginx/fastcgi_params;
> fastcgi_param SERVER_PORT 80;
> fastcgi_param HTTPS $fastcgi_https;
> }
> }
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,260265,260265#msg-260265
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
--
Steve Holdoway BSc(Hons) MIITP
http://www.greengecko.co.nz
Linkedin: http://www.linkedin.com/in/steveholdoway
Skype: sholdowa
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx