期待已久的 WordPress 5.9在2022.1.25終於來了,支持整站編輯,剛更新就發生了最重要的編輯器不能打開的問題。折騰了一番,終於找到問題所在,謹記下以備忘。
之前,參考某站的優化措施 (https://free.com.tw/wordpress-optimization-guide/),其中一條是“移除掉不必要的查詢參數”,在 「.htaccess」中加入了以下幾行:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} !=””
RewriteCond %{QUERY_STRING} !^p=.*
RewriteCond %{QUERY_STRING} !^s=.*
RewriteCond %{REQUEST_URI} !^/wp-admin.*
RewriteRule ^(.*)$ /$1? [R=301,L]
</IfModule>
只要在「.htaccess」中把這幾行去掉後,問題就解決了。
官網討論區有相關的話題(https://wordpress.org/support/topic/anyone-try-the-twenty-twenty-two-theme/#post-15331006)。該話題經詳細討論,大致是關於把wp安裝在子目錄中產生的問題。最後得以解決:https://wordpress.org/support/topic/anyone-try-the-twenty-twenty-two-theme/page/2/
摘錄如下:
Hello everyone,
my hosting provider kinda solved the issue adding the following line:Header always set Content-Security-Policy "upgrade-insecure-requests;"
in subfolder’s .htaccess (outside BEGIN/END WordPress of course).
So, just to summarize the things to check (most of them are obvious):
- You should specify your subfolder in root’s index.php require statement
require __DIR__ . '/(your_subfolder)/wp-blog-header.php';
- Root’s .htaccess should be left as it is when WP creates it.
- Subfolder’s index.php should not have the
/(your_subfolder)
part in its require statement. - Subfolder’s .htaccess should contain the line I mentioned at the beginning.
- In WP Settings > General you should state your subfolder’s name in WP’s URL and not state it in website’s URL (as you normally would with a subfolder installation).
For those interested in delving into the .htaccess statement, here’s MDN link.
Cheers!
有人用 http 就能正常,用 https 就出錯,有這方面問題的可以試試朝「混合安全和非安全內容在同一網頁」這方面想想,或去這裡看看: install plugins that automatically redirect all the we HTTP requests to HTTPS requests
我也試過在Chrome安裝過某些油猴插件(Tampermonkey Plugin)導致白頁,可以先把Chrome 的所有插件包括Tampermonkey關掉,也許就能解決問題。
發佈留言