How to run Wordpress admin on a different subdomain?

后端 未结 5 1889
刺人心
刺人心 2021-02-14 10:55

I have the requirement of running the Wordpress admin over https. We use a cdn to deliver cached content for the site but the cdn cannot accept secure traffic (only one SSL cert

5条回答
  •  一生所求
    2021-02-14 11:52

    To enable admin access for http://blog.example.com through https://ssl.example.com/wp-admins/blog/wp-login.php with pure Apache config so you have no dependence on Wordpress plugins and updates you may want to...

    ...use mod_proxy on an HTTPS apache virtual host to forward traffic, ensure ProxyPreserveHost is Off so that host names in the proxy statements are sent through to the wordpress server. Then mod_substitute is used (make sure to turn it on) to fix the broken links coming back from wordpress.

    
    
      AddOutputFilterByType SUBSTITUTE text/html
      AddOutputFilterByType SUBSTITUTE text/css
      AddOutputFilterByType SUBSTITUTE application/javascript
      AddOutputFilterByType SUBSTITUTE application/json
      Substitute "s|http://blog.example.com|https://ssl.example.com/wp-admins/blog|i"
      Substitute "s|blog.example.com\\\/|blog.example.com\\/wp-admins\\/blog\\/|i"
      Substitute "s|'/wp-admin|'/wp-admins/blog/wp-admin|i"
      Substitute "s|\"/wp-admin|\"/wp-admins/blog/wp-admin|i"
      Substitute "s|'/wp-includes|'/wp-admins/blog/wp-includes|i"
      ProxyPassReverseCookiePath / /wp-admins/blog/
    
    
    
    ProxyPass /wp-admins/blog/ http://blog.example.com/
    ProxyPassReverse /wp-admins/blog/ http://blog.example.com/
    

    For the reverse proxy to work, you need to specify the internal IP of the server hosting blog.example.com. This solution ensures this will work even if the upstream server (10.0.0.4) has several name-based virtual hosts.

    10.0.0.4 blog.example.com
    

    For more details, see:

    http://tec.libertar.se/how-to-host-wordpress-admin-on-a-seperate-domain-and-subfolder/

提交回复
热议问题