How to redirect www to no-www in EE V4?

I have 3 days trying to make it works, but i can’t, in V3 it was easy but in V4 is hard, i have been searching in the forum but there is not a solution that works.

Someone can help me with this?

Thanks in advance.

I have created a file /var/lib/docker/volumes/global-nginx-proxy_confd/_data/xyz.com-redirect.conf, with the follwing content:

server {
	listen  80;
	server_name  www.xyz.com;
	return  301 https://xyz.com$request_uri;
}
server {
	listen  443;
	server_name  www.xyz.com;
	return  301 https://xyz.com$request_uri;
}

It works well on all my sites
No special permissions, but you must run “ee site restart xyz.com

Thanks. i will try.

This may not be the answer you are looking for, but I never experience issues with www redirecting to non-www when I follow EE4 setup instructions, especially when using LE SSL.

Make sure that there is a CNAME record pointing www to your webserver, or an A record for WWW pointing to your webserver. Then create the site using only the non-www domain name.

I have done this dozens of times and every site redirects the www to the non-www version of the site without fail.

Perhaps you can let us know the process you use to setup new sites in EE4? This detail should not be an issue in EE4 and you should not have to modify config files. If you share your process and we can duplicate the issue, it may lead to a more integrated solution.

In fact i solve it of this way, i didn’t have the www register in DNS, i asked and reinstalled wordpress and works.

Thanks to everybody for the help.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.