为什么我的.htaccess重定向在测试期间返回200而不是301?

我们有一个WordPress站点,由于一些问题它被改变了几次,从非www到www。主要问题是谷歌索引了两个版本,这不好。最终我们选择了www,并希望从现在开始非www不能直接访问。这里是我们在.htaccess中使用的代码:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

尽管有一些奇怪的行为和混合测试结果,这基本上是有效的。当我在Google Chrome的隐身模式下测试时,我键入https://theaksesuar.com,首先它只是连接并显示我们网站的一些扭曲版本。当我刷新页面时,它会重定向到https://www.theaksesuar.com并正确显示页面。

重定向检查器和大多数其他重定向检查器报告200而不是301: https://www.redirect-checker.org

https://theaksesuar.com 200 OK

HTTP Headers
>>> https://theaksesuar.com

> --------------------------------------------
> 200 OK
> --------------------------------------------

Status: 200 OK
Code:   200
Server: openresty
Date:   Fri, 14 May 2021 07:50:51 GMT
Content-Type:   text/html; charset=UTF-8
Connection: close
Accept-Ranges:  bytes
Age:    153515
Cache-Control:  max-age=2592000
Content-Security-Policy:    upgrade-insecure-requests
Expires:    Fri, 11 Jun 2021 13:12:16 GMT
Last-Modified:  Wed, 12 May 2021 09:57:00 GMT
Strict-Transport-Security:  max-age=31536000; includeSubDomains
Vary:   Accept-Encoding, User-Agent
X-Backend:  local
X-Cache:    cached
X-Cache-Hit:    HIT
X-Cacheable:    YES
X-Content-Type-Options: nosniff
X-Xss-Protection:   1; mode=block

https://redirectdetective.com/ 报告301良好。如果有人能帮忙,我会很高兴。

最好的问候,

点赞