Как настроить wp-json в nginx?
Пытаюсь настроить wp-json, но nginx ругается. Выдаёт ошибку 404 Подскажите что не так в моём конфиге
location /wordpress/ {
index index.php index.html index.htm;
try_files $uri $uri/ /wordpress/blog/index.php?$args;
#try_files $uri $uri/ /index.php;
}
location ~ ^/wordpress/wp-json/ {
rewrite ^/wordpress/wp-json/(.*?)$ /?rest_route=/$1 last;
}
Ответы (1 шт):
Автор решения: Danila Vershinin
→ Ссылка
Нашёл откуда взялся второй location) Но думаю тем не менее это не всегда необходимо. В любом случае заработает если вы измените rewrite, учитывая что блог в сабдиректории:
location /wordpress/ {
index index.php index.html index.htm;
try_files $uri $uri/ /wordpress/blog/index.php?$args;
#try_files $uri $uri/ /index.php;
}
location ~ ^/wordpress/wp-json/ {
rewrite ^/wordpress/wp-json/(.*?)$ /wordpress/?rest_route=/$1 last;
}