gpt4 book ai didi

WordPress 网站不断重定向到 no-www

转载 作者:行者123 更新时间:2023-12-04 02:43:08 24 4
gpt4 key购买 nike

我最近推出了 3 个新的 WordPress 网站,出于某种原因,它们都出现了重定向循环。前往 www.example.com 会重定向到 example.com。在其中一个网站上,我刚刚决定坚持使用非 www,因为它是一个全新的网站,但是我需要在其他网站上强制使用 www。

到目前为止,我已经尝试了以下方法:

  • 更改 .htaccess 以强制 www — 没用
  • wp-config.php 中定义我的博客和网站 url — 没用
  • 已更新数据库,从 www.example.com 更改为 example.com 并返回 www.example.com 只是尝试重置它——没用

直到最近我才遇到过这个问题。

最佳答案

该问题实际上与 WordPress 无关。最近升级到 Plesk 11.5 后,域的“主机设置”中有一个选项是错误的。该设置称为“首选域”。

首选域:

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.

出于某种原因,它默认为“domain.tld”,但应设置为“None”。这立即解决了问题,现在 WordPress 不会进入重定向循环。

修改步骤如下:

  1. 转到您的域名
  2. 点击“网站和域名”
  3. 点击域名上的“Hosting Settings”
  4. 找到“首选域”并选择“无”

关于WordPress 网站不断重定向到 no-www,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19461621/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com