Redirecting not www to www causes an endless loop

I tried to redirect the Wordpress website using .htaccess, but it causes an infinite loop to form. Now there is no redirect for the blog. However, the domain URL with www is automatically redirected to non-www. I checked the whole server and I am sure there is no redirect on the server. I also tried to change the site address and the Wordpress address in the control panel, but it still creates an endless loop.

There is nothing redirecting in the template because I tried to create a simple test .html file and still the same.

Note. I don’t think the code matters here, because the question is where this WWW was redirected not to www, which I didn’t indicate in my code or on the server

RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L] 

update: I just found out about it. Plesk configuration files are really complex, distributed in many places. I see that the rewrite rule has been added to conf conf inside the website name. I deleted this and changed the site url and now everything is working fine. Thank you for your support.

+3
source share
1 answer

You do not need to edit htaccess. You can do this more safely by specifying your preferred URL in the settings.

enter image description here

If you have domain.comand you want users to be redirected to www.domain.com, save www.domain.comin the settings and vice versa. Wordpress will manage the www redirect.

Similarly, you can also control the path if you want users to see example.com/blog.

+8

All Articles