このバグは私にとって非常に辛いことです。ワードプレスでは、新しい投稿や既存の投稿を更新または保存した後、いつかは404ページにリダイレクトされます。これはランダムに起こります。根本原因を特定することはできません。
いくつかの同様の投稿、http://wordpress.org/support/topic/404-error-after-dit-gt-update-post[this]とhttp://wordpress.org/support/topic/clicking-updateを読んだ後-page-results-in-a-404[this]、これはApache上にインストールされた `mod__security`フィルタリングによるものであることを発見しました - 投稿に" exec "や" SQL "のようなあらかじめ定義された危険な" 「挿入」のようなコマンドを挿入すると、投稿はフィルタにかけられ、WordPressは404ページだけを返します。
私の解決策は次のとおりです。
1. mod__securityを無効にする
.htaccess`に以下のルールを入れて
mod__security`モジュールを無効にすることを提案しています。
#... <IfModule mod__security.c> SecFilterEngine Off SecFilterPost Off </IfModule> <IfModule mod__env.c> SetEnv MODSEC__ENABLE Off PassEnv MODSEC__ENABLE </IfModule> #...
残念ながら、上記の解決策は私のために働いていません。
httpd.conf`を見つけて、私のApacheが最新の
mod__secuirty2`を使っているのを見つけたら、再びルールを守ろうとします:
#... <IfModule mod__sec2.c> SecFilterEngine Off SecFilterPost Off </IfModule> #...
しかし、どちらも動作していません。あなたはあなたの運を試すことができます:)
2.バイパスmod__securityルール
グーグルでは、
` mod__security 2
"がもはや` .htaccess`オーバーライドをサポートしていないことを知り、手動で設定ファイルを使ってこれらのルールをバイパスする必要があります。
これを修正するには、 `/usr/local/apache/conf/modsec2/exclude.conf`を見つけて、ファイルの先頭に以下の内容を追加してください。
/usr/local/apache/conf/modsec2/exclude.conf
<locationmatch "/wp-admin/post.php"> SecRuleRemoveById 300013 SecRuleRemoveById 300015 SecRuleRemoveById 300016 SecRuleRemoveById 300017 </locationmatch>
WordPressは
/wp-admin/post.php`を使って投稿を更新しますが、今度は
mod__security`が300013,300015,300016,300017のルールをバイパスします。
Apacheサーバーを再起動します。以前の問題の投稿をもう一度更新してください。これで正常に更新され、404ページにリダイレクトされなくなりました。
3.フィルタするルールID
さて、フィルタリングするルールはどのように分かっていますか?この情報は `modsec__audit.log`で見つけることができます - すべてのフィルタリングされたURLまたはインターセプトされたURLがこのファイルに記録されます。
/usr/local/apache/logs/modsec__audit.log
# your problem-post URL here... --2950df1e-H-- メッセージ:コード500でアクセスが拒否されました(フェーズ2)。 ([|:スペース|]]+[A-Z | a-z | 0-9 | \ \ ** | |[\:]+[[:space:]]+(from | |テーブル|データベース|インデックス|ビュー)[[:space:]]+[A-Z | a-z | 0-9 | \\ ** | | \\、]| UNION SELECT。** \\ '。** \\'。** 、[0-9]。** INTO。** FROM)をREQUEST__BODYに設定します。 [file "/usr/local/apache/conf/modsec2.user.conf"][line "345"][id "300013"][rev "1"] [msg "Generic SQL injection protection"][severity "CRITICAL"] アクション:インターセプト(フェーズ2) #...
Filter by URL or your IP, to identify which rules are triggered when you update the post. In the above case, the post’s URL hits rule “ 300013 “, and you need to bypass this rule id in order to update the post.
-
Note**
Check yourhttp.conf
,mod__security
logs may have logged the error messages to somewhere else, do consult your hosting provider for detail.
References
-
http://www.modsecurity.org/blog/archives/2007/12/using transacti.html[Using Transactional Variables Instead of SecRuleRemoveById]. 404 error after editing update post . Clicking update page result in a 404 . WordPress error 404 when publishing or saving post . WordPress mod security 2 . Weird 500 internal server error on WordPress resolved 404 mod__security wordpress