Ecommerce Shopify WordPress Discussion

WP behind a Reverse Proxy – 301 redirect in loop – Nginx

I am trying to forward/proxy all the traffic from only blog links from my old worpress website that is https://old_wordpress_host.com/blog to new host https://new_wordpress_host.com/ nginx block for proxy on old_wordpress_host.com.conf location ^~ /blog { rewrite ^/blog(/.*)$ $1 break; proxy_ssl_server_name on; proxy_pass_request_headers on; proxy_pass https://new_wordpress_host.com/; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; server_name_in_redirect off; } And then in wordpress wp-config.php on new wordpress new_wordpress_host.com define('.COOKIE_DOMAIN.', 'old_wordpress_host.com'); define('.SITECOOKIEPATH.', '.'); if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']); $_SERVER['REMOTE_ADDR'] = $list[0]; define('WP_SITEURL', 'https://old_wordpress_host.com/blog/'); define('WP_HOME', 'https://old_wordpress_host.com/blog/'); $_SERVER['HTTP_HOST'] = 'old_wordpress_host.com'; $_SERVER['REMOTE_ADDR'] = 'https://old_wordpress_host.com'; $_SERVER[ 'SERVER_ADDR' ] = 'old_wordpress_host.com'; if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){ $_SERVER['HTTPS']='on'; } }
rewrite rule in your Nginx configuration is unnecessary since you're handling the path with proxy_pass. remove rewrite rule once and check again location ^~ /blog { proxy_ssl_server_name on; proxy_pass_request_headers on; rewrite ^/blog(/.*)$ $1 break; proxy_pass https://new_wordpress_host.com; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; server_name_in_redirect off; } in wp-config.php you're trying to set the cookie domain and site URL to the old host but it should be the new host define('COOKIE_DOMAIN', 'new_wordpress_host.com'); define('.SITECOOKIEPATH.', '.'); if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']); $_SERVER['REMOTE_ADDR'] = $list[0]; $_SERVER['HTTP_HOST'] = 'new_wordpress_host.com'; define('WP_SITEURL', 'https://new_wordpress_host.com/'); define('WP_HOME', 'https://new_wordpress_host.com/'); $_SERVER['REMOTE_ADDR'] = 'https://old_wordpress_host.com'; $_SERVER[ 'SERVER_ADDR' ] = 'old_wordpress_host.com'; if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){ $_SERVER['HTTPS']='on'; } }

January 7, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.