basically as title says i got a wp behind reverse proxy. Let's say, the domain is , and wordpress is ****/blog Here are the wp-config.php edits that allow it to work this way:
define('.ADMIN_COOKIE_PATH.', '/blog');
define('.COOKIE_DOMAIN.', 'www.***.com');
define('.COOKIEPATH.', '/blog');
define('.SITECOOKIEPATH.', '.');
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
$_SERVER['REMOTE_ADDR'] = $list[0];
}
define('DOMAIN_CURRENT_SITE', 'https://www.***.com/blog');
define('WP_HOME','https://www.***.com/blog');
define('WP_SITEURL','https://www.***.com/blog');
$_SERVER['REMOTE_ADDR'] = 'https://www.***.com/blog';
$_SERVER['HTTP_HOST'] = 'www.***.com/blog';
$_SERVER[ 'SERVER_ADDR' ] = 'www.***.com/blog';
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
$_SERVER['HTTPS']='on';
$_SERVER['REQUEST_URI'] = str_replace("https://www.***.com/wp-admin",
"https://www.***.com/blog/wp-admin",
$_SERVER['REQUEST_URI']);
Now, it all works perfectly, but when I m in some places in admin panel, lets say comments, if i submit forms, WP goes to */wp-admin instead of */blog/wp-admin and crashes to 404.
UPDATE
tried the VHost approach, added this to my httpd.conf
Listen 80 <VirtualHost *:80>
DocumentRoot /var/www/wp-admin
ServerName https://***/blog/wp-admin
# Other directives here
</VirtualHost>
but strangely got a redirect loop whenever i go to /blog after this
How do I fix this?
$_SERVER['REQUEST_URI'] do not contains the full URL, so you should replace only /wp-admin/. Given your example:
$_SERVER['REQUEST_URI'] = str_replace("/wp-admin/", "/blog/wp-admin/",
$_SERVER['REQUEST_URI']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With