Я хотел бы интегрировать свой блог WP в сайт без WP, используя WP API.
Мой блог в настоящее время находится на site.com/blog
, поэтому API размещен на site.com/blog/wp-json
Мой не-WP сайт на site.com
Когда пользователь посещает site.com/blog
или site.com/blog/<slug>
Я бы хотел обслуживать не WP-сайт, но если я посещаю site.com/blog/wp-json/*
или site.com/blog/wp-admin
(в основном что-либо с /blog/wp-*
), которое будет обслуживаться Wordpress.
Яиспользуя Nginx и настройте его в sites-available
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
rewrite ^/([^/]+)\/([^/]+)/[0-9]+.html$ /vinyl/$1-$2/ permanent;
#add_header Cache-Control 'no-store';
}
location ~ /blog/.*\.php$ {
root /var/www/websitename;
index index.php index.html index.htm;
set $php_root /var/www/websitename/blog;
include /etc/nginx/fastcgi_params;
try_files $uri =404;
fastcgi_read_timeout 180;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
location /blog {
root /var/www/websitename;
index index.php index.html index.htm;
set $php_root /var/www/websitename/blog;
try_files $uri $uri/ /blog/index.php$is_args$args;
}