简体   繁体   English

WordPress URL 不以斜杠结尾重定向到 HTTPs 主页

[英]WordPress URLs not ending with a slash redirect to HTTPs homepage

I have a mystery: for my blog,我有一个谜:对于我的博客,

  • HTTP URLs that do not end with a slash (eg http://yal.cc/about ) redirect to the HTTPS homepage ( https://yal.cc ) rather than the HTTPS version the URL. HTTP URLs that do not end with a slash (eg http://yal.cc/about ) redirect to the HTTPS homepage ( https://yal.cc ) rather than the HTTPS version the URL.
  • HTTP URLs that do end with a slash (eg /about/ ) redirect correctly. HTTP以斜线结尾的 URL(例如/about/ )正确重定向。
  • HTTP URLs that correspond to actual server directories (eg /game-tools ) also redirect correctly. HTTP 对应于实际服务器目录(例如/game-tools )的 URL 也可以正确重定向。
  • HTTP URLs on a subdomain (eg http://ru.yal.cc/about ) also redirect correctly. HTTP 子域上的 URL(例如http://ru.yal.cc/about )也可以正确重定向。
    (subdomain is a separate WordPress installation in a different directory that uses the same theme/plugins/ .htaccess ) (子域是一个单独的 WordPress 安装在使用相同主题/插件/ .htaccess的不同目录中)

My .htaccess is nothing unusual:我的.htaccess没什么异常:

# BEGIN rlrssslReallySimpleSSL rsssl_version[4.0.7]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# END rlrssslReallySimpleSSL
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Things that I have tried to no success:我尝试过但没有成功的事情:

  • Disabling all plugins禁用所有插件
  • Removing ReallySimpleSSL's redirect from .htaccess.htaccess删除真正简单 SSL 的重定向
  • Switching the theme to TwentyTwentyOne将主题切换到 TwentyTwentyOne
  • Adding this little hack添加这个小技巧
  • Verifying that "base URL" uses HTTPS (it does)验证“基本 URL”是否使用 HTTPS(确实如此)
  • Changing permalink format to /%postname% instead of /%postname%/将永久链接格式更改为/%postname%而不是/%postname%/
  • Comparing configuration of two websites in Plesk (nothing seems different; "Permanent SEO-safe 301 redirect from HTTP to HTTPS" is not enabled)比较 Plesk 中两个网站的配置(似乎没有什么不同;“从 HTTP 到 HTTPS 的永久 SEO 安全 301 重定向”未启用)

Where would I start with debugging this?我从哪里开始调试呢? This proves a mild inconvenience since most of the pre-2019 links to my website were http without trailing slashes, meaning that they are now broken without any way to indicate to the user that their subject of search is still there - a slash away.这证明了轻微的不便,因为到我网站的大多数 2019 年之前的链接都是 http 没有尾部斜杠,这意味着它们现在被破坏,没有任何方式向用户表明他们的搜索主题仍然存在 - 一个斜杠。

So, it's unclear which of the things listed in the question has helped, but I have apparently fixed it.因此,尚不清楚问题中列出的哪些内容有所帮助,但我显然已经修复了它。

If I were to guess, the original rule in .htaccess was malformed and had been fixed while I was enabling-disabling it (which would have been prior to making a copy that's in the question) - I did undo the rest of the changes after (incorrectly) verifying whether they worked.如果我猜的话, .htaccess中的原始规则格式不正确,并且在我启用-禁用它时已修复(这将在制作问题中的副本之前) - 我确实撤消了 rest 之后的更改(错误)验证它们是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM