1

I have new wordpress website and existing rails app on two different servers. I wanted my wordpress website to be https://example.com/blog

My current nginx config for mydomain.com is

location /blog {
proxy_pass http://<ip-address of wp server>;
proxy_http_version                  1.1;
proxy_set_header  Connection        "";
proxy_set_header  Host              $host;
proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
proxy_set_header  X-Real-IP         $remote_addr;
}

My wordpress config is

$_SERVER['HTTPS'] = 'on';
define('WP_HOME', "https://example.com/blog");
define('WP_SITEURL', "https://example.com/blog");

Everything is working fine(admin and home page) But when i click on post-page on hover its showing right url which is https://example.com/blog/post but its redirecting to https://example.com/post

1 Answer 1

1

I managed to solve this by changing my nginx config

    location /blog {
  proxy_set_header  X-Real-IP  $remote_addr;
  proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_redirect false;

  if (!-f $request_filename) {
    rewrite ^/blog$     /;
    rewrite ^/blog/(.*)$ /$1;
    proxy_pass http://blog.domain.com;
    break;
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.