【发布时间】:2017-11-27 08:58:02
【问题描述】:
我正在开发一个 Wordpress 网站。当 http 版本被重定向到 https 时,它会给出 302 Found 通知,如下所示:
curl -I http://www.example.com
HTTP/1.1 302 Found
Date: Mon, 27 Nov 2017 08:33:15 GMT
Server: Apache
Location: https://www.example.com/
Content-Type: text/html; charset=iso-8859-1
我无法弄清楚到底是什么触发了这个。 .htaccess 文件有以下内容:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
上面的前 3 行似乎对我保留或删除它们没有任何影响。
在 cPanel > Redirects 中或通过 Wordpress 中的重定向插件没有设置 http 到 https 的重定向。
但是,作为实时站点的精确副本的开发站点不存在此问题。当我在开发网站上使用 curl 时,它给了我 301 Moved Permanently,这是我在现场网站上所期望的:
curl -I http://dev.example.com
HTTP/1.1 301 Moved Permanently
Date: Mon, 27 Nov 2017 08:41:53 GMT
Server: Apache
X-Pingback: http://dev.example.com/wordpress/xmlrpc.php
Expires: Mon, 27 Nov 2017 09:41:55 GMT
Cache-Control: max-age=3600
Location: https://dev.example.com/
Vary: User-Agent
Content-Type: text/html; charset=UTF-8
我不知道该去哪里找。该站点在 VPS/Centos 7/Apache 中运行。任何帮助将不胜感激。
【问题讨论】:
-
你可以访问apache配置文件吗?
-
@DusanBajic 你的意思是
httpd.conf文件?是的,我愿意。我调查了它,但不确定其中是否有任何相关内容。也许我不确定我应该看什么。你能告诉我我应该在那个文件中寻找什么吗? -
是的,httpd.conf 或 conf.d/ 文件夹中的任何 .conf。寻找
RewriteRules 或Redirects -
您是否尝试过缓存清除技术来查看重定向是否缓存在任何地方?它可能被缓存在一个意想不到的地方,比如代理。
-
@DusanBajic 感谢您的提示。就像你说的,它确实是另一个 .conf 文件中的
Redirect指令。我已经发布了一个答案,所以这可以帮助其他人。谢谢!
标签: wordpress apache .htaccess centos7 http-status-code-302