Wordpress Redirect Issues

Seems to be a few redirect issues I am seeing. Seems the problems are within the /var/lib/docker/volumes/global-nginx-proxy_confd/_data/testsite.com-redirect.confg settings.

After setting up a test site with the below command wordpress is setup correctly and runs without issue. Unless you want to set your URL to www.testsite.com. If you set the WordPress Address and Site Address to https://www.testsite.com your site will now be stuck in a 301 redirect loop. The default settings in the conf file also cause redirect problems with http to https, non-www to www, www to non-www.

ee site create testsite.com --type=wp --ssl=le --cache

I am sure this isn’t the ideal way to fix the issue but below is the info I had to change to get all the redirect issues to stop.

server {
	listen  80;
	server_name  testsite.com www.testsite.com;
	return  301 https://www.testsite.com$request_uri;
}
server {
	listen  443;
	ssl_protocols TLSv1.2 TLSv1.3;
	ssl_ciphers '*******';
	ssl_prefer_server_ciphers on;
	ssl_session_timeout 5m;
	ssl_session_cache shared:SSL:50m;
	ssl_session_tickets off;
	ssl_certificate /etc/nginx/certs/testsite.com.crt;
	ssl_certificate_key /etc/nginx/certs/testsite.com.key;
	server_name  testsite.com;
	return  301 https://www.testsite.com$request_uri;
}

To create a WP website that uses WWW try using the WWW when creating a new website as follows:

ee site create www.testsite.com --type=wp --ssl=le --cache

Tell me if that work for you.

Yeah I never really use www but on one of my domains just now to test it I created it with the www and with a wildcard certificate and cache etc. I didn’t have a single issue. Just make sure you’re ee is up to date.

@mikeslv On v3 setting up a site with the www sub-domain wouldn’t create the nginx config correctly because it would not correctly handle the requests to the main URI. Example, setting up example.com on v3 would setup the config so that example.com and www.example.com would go to the same site. Setting up www.example.com in ee v3 would make it where www.example.com would work but example.com wouldn’t go to the correct location. I am not sure if it is the same with v4 but either way, they config is setup wrong by default.

@msarhan I am not sure if you have SSL setup on that domain or not but I have the latest version of v4 on a new server for this test and it doesn’t work as you state it does.