WordPress, nginx proxy and subdirectory: wp-login.php redirects to domain

前端 未结 2 1297
甜味超标
甜味超标 2020-12-10 15:13

In my NGINX configuration, a WordPress blog is on a private server. My NGINX public server proxies the private server\'s content for https://www.example.com/blog/.<

相关标签:
2条回答
  • 2020-12-10 15:44

    I have also met with same problem, I found a workaround, to fix the issue, add below code to wp-config.php

    $_SERVER['REQUEST_URI'] = str_replace("/wp-admin/", "/blog/wp-admin/",  $_SERVER['REQUEST_URI']);
    
    0 讨论(0)
  • 2020-12-10 15:47

    WordPress uses two variables to define where it is hosted: WP_HOME and WP_SITEURL. Both can be set using the dashboard, but I prefer to set them in wp-config.php:

    define( 'WP_SITEURL', 'https://www.example.com/blog' );
    define( 'WP_HOME', 'https://www.example.com/blog' );
    

    It is usual to set an absolute URL (as above) which includes scheme and host name, but I prefer to use a relative URL when operating behind a reverse-proxy, like this:

    define( 'WP_SITEURL', '/blog' );
    define( 'WP_HOME', '/blog' );
    

    You can probably continue to run WordPress in the root of your private server (assuming it isn't accessed directly). Moving the private server down one level is a little more complicated and involves the web server configuration on both servers to be changed a little.

    0 讨论(0)
提交回复
热议问题