R
R
Roman Basharin2017-01-07 05:17:58
Nginx
Roman Basharin, 2017-01-07 05:17:58

OpenServer, Nginx, how to host 2 sites on the same domain?

I’m completely confused, I won’t unravel without advice)
WordPress is hanging on the site.com domain.
It is necessary to make a "single entry point at the address site.com/lp/
That is, everything that does not start with /lp/ goes to WordPress for processing, everything else is exclusively on index.php which lies in the /lp/ subdirectory.

location / {
        root       "%hostdir%";
        index      index.php index.html index.htm;
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    location /lp/.* {
        root       "%hostdir%";
        index      index.php;
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }

At the moment, the config is like this, but it does not work as it should. When I try to go to site.com/lp/one/two/three, a WordPress 404 error pops up.
Either something needs to be done with %hostdir%, or the regular expression is crooked, I don’t understand.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Роман Башарин, 2017-01-08
@Hellek

Нашел решение. Пока всё работает исправно.

root       "%hostdir%";
index      index.php index.html index.htm;

location / {
    try_files  $uri $uri/ /index.php?q=$uri&$args;
}

location /lp {
    try_files  $uri $uri/ /lp/index.php?q=$uri&$args;
}

K
ky0, 2017-01-07
@ky0 Куратор тега Nginx

Сделайте первый локейшен /lp - для вордпресса, второй, / - для всего остального, с редиректом на /lp. Регулярка тут ни к чему.

location /lp {
...тут ваши настройки вордпресса
}

location / {
return 301 $scheme://$host/lp/;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question