Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress sites keep redirecting to no-www

I recently launched 3 new WordPress sites and for some reason they are all getting redirect loops. Going to www.example.com redirects to example.com. On one of them I have just decide to stick with the non-www since it was a brand new site, however the others I need to force the www.

So far I have tried the following:

  • Changing .htaccess to force www — Did not work
  • Defining my blog & site url in wp-config.php — Did not work
  • Updated database changing from www.example.com to example.com and the back to www.example.com just trying to reset it — Did not work

I've never experienced this issue before until recently.

like image 661
doitlikejustin Avatar asked Jan 24 '26 18:01

doitlikejustin


1 Answers

The issue actually had nothing to do with WordPress. After recently upgrading to Plesk 11.5 there is an option in the domain's "Hosting Settings" that was wrong. The setting is called "Preferred domain".

Preferred domain:

Regardless of the domain's URL that visitors specify in a browser (with the www prefix or without it), a page with the preferred domain's URL opens. The HTTP 301 code is used for such a redirection. The 'None' value means that no redirection is performed.

For some reason it defaults to "domain.tld" but it should be set to "None". This fixes the problem instantly and now WordPress does not go into a redirect loop.

Here are the steps to change it:

  1. Go to your domain name
  2. Click on "Websites & Domains"
  3. Click on "Hosting Settings"on the domain name
  4. Find "Preferred domain" and select "None"
like image 200
doitlikejustin Avatar answered Jan 27 '26 14:01

doitlikejustin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!