php - 试图禁止 wordpress 重定向到 https
问题描述
我希望建立一个没有 https 的 wordpress 站点的测试版本,这样我就可以解决自从它转移到新的托管服务后出现的各种问题。
测试站点正在重定向到 https - 它返回指向活动域的 301!
我正在使用 nginx,因此 .htaccess 文件被忽略(其他问题的根源)。
该站点确实可以正确提供非 php 内容,并且其中包含 phpinfo() 的 .php 文件已正确提供。所以它似乎是wordpress或插件问题。
所以我重命名了插件目录以禁用所有插件并重新启动,重定向仍然发生!我已经清除了 nginx 的缓存和浏览器的缓存。
如何进一步诊断问题?下面我为测试站点复制了我的 nginx 配置。
thebe 上 testdomain.com 的声明。
服务器 { server_name testdomain.com; 听 80;
fastcgi_read_timeout 300;
root /home/ian/websites/testdomain/htsecure;
index index.php;
fastcgi_index index.php;
#
access_log /var/log/nginx/testdomain.access.log;
error_log /var/log/nginx/error.log;
#
location = /favicon.ico {
log_not_found off;
access_log off;
}
# disallow hot linking to images
location ~ .(gif|png|jpg|jpeg)$ {
valid_referers none blocked testdomain.com;
if ($invalid_referer) {
return 403;
}
}
# server static files that exist
location / {
try_files $uri $uri/ /index.php?$args;
}
# send .php files to fastcgi
location ~ \.php$ {
# Zero-day exploit defense - http://forum.nginx.org/read.php?2,88845,page=3
try_files $uri =404; # only if they exist!
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root@fastcgi_script_name;
include /etc/nginx/fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
解决方案
wp-config.php
通过将以下行添加到文件(在您的根目录中找到)来使用您的非 https 域配置 Wordpress :
define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );
背景
重定向可能是由以下几个原因引起的:
- 您的浏览器已经缓存了重定向(尝试从另一个浏览器加载站点)。
- 您的 DNS 配置不正确(这里不太可能出现问题)。
- 您的 Web 服务器 (nginx) 正在执行重定向,通过其全局配置、虚拟主机配置或(如果使用 apache)目录级配置(如果您可以加载其他 PHP 文件而无需重定向,那么可能不是 nginx问题)。
- 您的 PHP 代码正在执行重定向...可能在 Wordpress 中的任何位置...
理想情况下,您的 Wordpress 不会通过一些晦涩的代码来执行重定向——因此,禁用所有插件应该会停止重定向。但是,您可能错过的一种重定向是 Wordpress 本身立即执行的重定向,以强制站点仅从一个指定的“站点 URL”加载。
推荐阅读
- python - 合并填充的行单元格并忽略Python中的空单元格
- c++ - 在 c++ WWSAPI Web 服务中处理 WS-Security PasswordDigest 模式
- java - 我在 TLS 客户端身份验证中遇到错误“javax.net.ssl.SSLHandshakeException:证书验证格式错误”
- shell - Cat 直到 bash 中出现某些 nb
- python - 卷积层中的内积(矩阵乘法)
- c++ - Atmel Studio 7 设置 int = 0,返回 257
- java - 如何在等距 libgdx 中触摸它时获得平铺位置
- python - Sypder 的多个控制台比多处理更快?
- netsuite - 等待支持回复字段在 NetSuite 中的具体工作原理是什么?
- angular - 无法在以前隐藏的 cdkDropList 中删除元素