As explained here, WordPress has Automatic URL Redirects. However, it’s not based on .htaccess which WordPress keeps to a minimum.

Let’s say your “siteurl” setting (in the GUI) contains “www.”. If a visitor didn’t use “www”, how and in which file does WordPress manage to detect that and redirect accordingly?

1 Answer
1

The literal answer to your question is that wordpress uses wp_redirect() to perform redirects. You can see the source here https://developer.wordpress.org/reference/functions/wp_redirect/

The implied part of your question — about how wordpress decides when to do so — is a bit more complicated and might be influenced by plugins such as yoast. But, for example, if wordpress’s rewrite rules select a post which has a different canonical url from the requested url, wordpress may redirect to the canonical url.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *