I have tried to redirect a WordPress website using .htaccess but it causes to form an infinite loop. Now there is no redirection for the blog. Still the domain url with www is automatically redirecting to non www. I have checked whole server and I am sure that there is no redirect in the server. Also tried by changing the site address and WordPress address from dashboard but still creates infinite loop.
There is nothing redirection in template because I have tried by creating a simple .html test file and still the same.
Note: I don’t think code is relevant here because the question is where this www to non www redirection came which I haven’t given in my code or in the server
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
update:
I just found it out. Plesk configuration files is really tricky, spreads in many places. I can see that the rewrite rule was added in under conf within the website name. I have removed this and change the site url and now everything works fine. Thank you for your support
You don’t need edit htaccess. You can do it more safely by specifying the preferred URL in Settings.
If you have
domain.com
and want users to be redirected towww.domain.com
, then keepwww.domain.com
in the settings and vice versa. WordPress will manage the www redirection.Similarly you can manage path also, if you want users to see
example.com/blog
instead.