Setup multiple Stores, Store views and domains on NGINX
I was trying to setup multi stores and store views with different domains on NGINX.
Here is the structure of my website (sorry, I really don't know how to use the list):
- Main Website (only one)
- clothes (store)
- clothes_vi (store view, desired domain: vi.clothes.local)
- clothes_en (store view, desired domain: e.clothes.local)
- computer (store)
- computer_vi (store view, desired domain: vi.computer.local)
- computer_en (store view, desired domain: en.computer.local)
To achieve the desired domain above for each store view, I configured:
/etc/nginx/sites-available:
upstream fastcgi_backend {
server unix:/run/php/php7.1-fpm.sock;
}
map $http_host $MAGE_RUN_CODE {
en.computer.local computer_en;
vi.computer.local computer_vi;
en.clothes.local clothes_en;
vi.clothes.local clothes_vi;
}
server {
listen 80;
server_name en.computer.local vi.computer.local en.clothes.local vi.clothes.local;
set $MAGE_ROOT <project_dir>;
include <project_dir>/nginx.conf;
}
project_dir/nginx.conf:
Add:
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
Below:
fastcgi_param PHP_FLAG "session.auto_start=off n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=756M n max_execution_time=600";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
And set the above domain for each of the store view in store configuration.
With above configuration, when I go to the front-end and access each of the store view using the drop down list appeared there, with my configured domains. However, if I type in the url myself before using the drop down list, it'll redirect me to the url of default store view, which is vi.clothes.local.
Detailed cases:
Stay at vi.clothes.local, go to computer_en using the drop down list in front-end -> redirect to en.computer.local and the corresponding store.
Do case 1, then type en.computer.local on address bar -> the same correct result
Type en.computer.local on address bar without doing case 1, or use incognito mod -> redirect to vi.clothes.local and the default store.
Why this is happening and how to achieve my goal? Any help is appreciated please!
nginx magento2 magento2.2
add a comment |
I was trying to setup multi stores and store views with different domains on NGINX.
Here is the structure of my website (sorry, I really don't know how to use the list):
- Main Website (only one)
- clothes (store)
- clothes_vi (store view, desired domain: vi.clothes.local)
- clothes_en (store view, desired domain: e.clothes.local)
- computer (store)
- computer_vi (store view, desired domain: vi.computer.local)
- computer_en (store view, desired domain: en.computer.local)
To achieve the desired domain above for each store view, I configured:
/etc/nginx/sites-available:
upstream fastcgi_backend {
server unix:/run/php/php7.1-fpm.sock;
}
map $http_host $MAGE_RUN_CODE {
en.computer.local computer_en;
vi.computer.local computer_vi;
en.clothes.local clothes_en;
vi.clothes.local clothes_vi;
}
server {
listen 80;
server_name en.computer.local vi.computer.local en.clothes.local vi.clothes.local;
set $MAGE_ROOT <project_dir>;
include <project_dir>/nginx.conf;
}
project_dir/nginx.conf:
Add:
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
Below:
fastcgi_param PHP_FLAG "session.auto_start=off n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=756M n max_execution_time=600";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
And set the above domain for each of the store view in store configuration.
With above configuration, when I go to the front-end and access each of the store view using the drop down list appeared there, with my configured domains. However, if I type in the url myself before using the drop down list, it'll redirect me to the url of default store view, which is vi.clothes.local.
Detailed cases:
Stay at vi.clothes.local, go to computer_en using the drop down list in front-end -> redirect to en.computer.local and the corresponding store.
Do case 1, then type en.computer.local on address bar -> the same correct result
Type en.computer.local on address bar without doing case 1, or use incognito mod -> redirect to vi.clothes.local and the default store.
Why this is happening and how to achieve my goal? Any help is appreciated please!
nginx magento2 magento2.2
add a comment |
I was trying to setup multi stores and store views with different domains on NGINX.
Here is the structure of my website (sorry, I really don't know how to use the list):
- Main Website (only one)
- clothes (store)
- clothes_vi (store view, desired domain: vi.clothes.local)
- clothes_en (store view, desired domain: e.clothes.local)
- computer (store)
- computer_vi (store view, desired domain: vi.computer.local)
- computer_en (store view, desired domain: en.computer.local)
To achieve the desired domain above for each store view, I configured:
/etc/nginx/sites-available:
upstream fastcgi_backend {
server unix:/run/php/php7.1-fpm.sock;
}
map $http_host $MAGE_RUN_CODE {
en.computer.local computer_en;
vi.computer.local computer_vi;
en.clothes.local clothes_en;
vi.clothes.local clothes_vi;
}
server {
listen 80;
server_name en.computer.local vi.computer.local en.clothes.local vi.clothes.local;
set $MAGE_ROOT <project_dir>;
include <project_dir>/nginx.conf;
}
project_dir/nginx.conf:
Add:
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
Below:
fastcgi_param PHP_FLAG "session.auto_start=off n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=756M n max_execution_time=600";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
And set the above domain for each of the store view in store configuration.
With above configuration, when I go to the front-end and access each of the store view using the drop down list appeared there, with my configured domains. However, if I type in the url myself before using the drop down list, it'll redirect me to the url of default store view, which is vi.clothes.local.
Detailed cases:
Stay at vi.clothes.local, go to computer_en using the drop down list in front-end -> redirect to en.computer.local and the corresponding store.
Do case 1, then type en.computer.local on address bar -> the same correct result
Type en.computer.local on address bar without doing case 1, or use incognito mod -> redirect to vi.clothes.local and the default store.
Why this is happening and how to achieve my goal? Any help is appreciated please!
nginx magento2 magento2.2
I was trying to setup multi stores and store views with different domains on NGINX.
Here is the structure of my website (sorry, I really don't know how to use the list):
- Main Website (only one)
- clothes (store)
- clothes_vi (store view, desired domain: vi.clothes.local)
- clothes_en (store view, desired domain: e.clothes.local)
- computer (store)
- computer_vi (store view, desired domain: vi.computer.local)
- computer_en (store view, desired domain: en.computer.local)
To achieve the desired domain above for each store view, I configured:
/etc/nginx/sites-available:
upstream fastcgi_backend {
server unix:/run/php/php7.1-fpm.sock;
}
map $http_host $MAGE_RUN_CODE {
en.computer.local computer_en;
vi.computer.local computer_vi;
en.clothes.local clothes_en;
vi.clothes.local clothes_vi;
}
server {
listen 80;
server_name en.computer.local vi.computer.local en.clothes.local vi.clothes.local;
set $MAGE_ROOT <project_dir>;
include <project_dir>/nginx.conf;
}
project_dir/nginx.conf:
Add:
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
Below:
fastcgi_param PHP_FLAG "session.auto_start=off n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=756M n max_execution_time=600";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
And set the above domain for each of the store view in store configuration.
With above configuration, when I go to the front-end and access each of the store view using the drop down list appeared there, with my configured domains. However, if I type in the url myself before using the drop down list, it'll redirect me to the url of default store view, which is vi.clothes.local.
Detailed cases:
Stay at vi.clothes.local, go to computer_en using the drop down list in front-end -> redirect to en.computer.local and the corresponding store.
Do case 1, then type en.computer.local on address bar -> the same correct result
Type en.computer.local on address bar without doing case 1, or use incognito mod -> redirect to vi.clothes.local and the default store.
Why this is happening and how to achieve my goal? Any help is appreciated please!
nginx magento2 magento2.2
nginx magento2 magento2.2
asked Nov 16 '18 at 5:00
MeeMee
4529
4529
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53331709%2fsetup-multiple-stores-store-views-and-domains-on-nginx%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53331709%2fsetup-multiple-stores-store-views-and-domains-on-nginx%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown