最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How does WordPress redirect without using .htaccess?

programmeradmin3浏览0评论

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?

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?

Share Improve this question asked Jan 28, 2020 at 23:13 LWCLWC 1276 bronze badges 1
  • It would seem the class is setup and some work within /wp-includes/class-wp-rewrite.php. I'm looking into it further and learning new stuff - that's always good. – Admiral Noisy Bottom Commented Jan 28, 2020 at 23:47
Add a comment  | 

1 Answer 1

Reset to default 0

The literal answer to your question is that wordpress uses wp_redirect() to perform redirects. You can see the source here https://developer.wordpress/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.

发布评论

评论列表(0)

  1. 暂无评论