2

My WordPress site used to require htaccess rewrite rules to redirect non-www to www (or vice versa) and http to https. Without those rules, the site would be accessible at whatever URL the user requested (my installation is in the domain root). That was a few years ago.

Recently, after upgrading the site to WordPress 6, I noticed that whatever URL is specified in General Settings is now the only version of the URL that will load. Non-www and http requests are redirected via a 301. My htaccess does not have any rules besides the default WordPress rules.

Can anyone confirm that WordPress indeed redirects to the "WordPress Address" URL automatically or point me to an announcement or post where this change was discussed?

2 Answers 2

0

Recommend using htaccess to take care of SSL redirects as needed. Will prevent 'mixed content' errors.

I don't think WP does any redirects, other than to get the content. If your settings have non-SSL, that's what people will get. Using htaccess will prevent problems.

1
  • I'm not having any problems. I am seeing redirects to https and www without any work done on my part and am asking how that's accomplished on the WP's backend.
    – Dave
    Commented Sep 19, 2023 at 21:53
0

Generally, the best practice is to update the URL in the "Site Address" and "Wordpress Address" fields under settings Settings->General. You would also want to do a search and replace in the database, replacing the http url version for https (i.e. search http://example.com and replace with https://example.com–exactly the same but adding the s). There are great free plugins for this (like Better Search Replace).

You should always flush the permalinks after doing something like this, as a good practice (navigate to Settings->Permalinks and just click "Save" and the permalinks will be updated).

And yes, changing the site URL has generally caused Wordpress to redirect for a pretty long time (years) but I don't know when or if that changed, to be sure. Given how permalinks work, I'd imagine it was always like that but I recall thinking that it was something that changed at some point.

Lastly, an .htaccess 301 redirect is not a bad idea for SEO purposes, or at least adding a canonical link tag to the <head> of your site for every page. (Google seems to want you to do both, but just having one probably isn't a big risk, IMO.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.