У меня одна установка WordPress на сервере Ubuntu 20.04 NGINX. Доступ к большинству страниц WordPress будет осуществляться через основной домен example.com, но один раздел будет доступен только через второй домен example.net. Как мне изменить мою текущую конфигурацию NGINX ниже, чтобы это произошло? У меня будет только одна установка WordPress в одном каталоге (кроме test.example.com).
server {
listen 80;
server_name www.example.com;
# www to non-www for SEO canonical reasons
return 301 http://example.com$request_uri;
}
server {
listen 80;
server_name example.com;
root /var/www/example.com/html;
index index.php index.html index.htm index.nginx-debian.html;
# PHP
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
location = /favicon.ico {
log_not_found off; access_log off;
}
location = /robots.txt {
log_not_found off; access_log off; allow all;
}
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
}
# (For WordPress permalinks)
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
}
server {
listen 80;
server_name test.example.com;
root /var/www/example.com/test;
index index.php index.html index.htm index.nginx-debian.html;
# PHP
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
location = /favicon.ico {
log_not_found off; access_log off;
}
location = /robots.txt {
log_not_found off; access_log off; allow all;
}
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
}
# (For WordPress permalinks)
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
}
Новый серверный блок - это решение:
server {
listen 80;
server_name www.example.net;
root /var/www/example/othersection;
}