問題の概要
商品カテゴリーから商品カテゴリーの翻訳を手動で編集した際、(スラッグではなく)カテゴリーの説明/テキストのみを変更した場合でも、Yoast SEO Premiumが誤って301リダイレクトを作成していました。
作成されたリダイレクトのURLは不正な形式になっています。
古いURL: http://site.com/product-category/test-es-wpml
新しいURL: http://site.com/http://es.site.com/product-category/test-es-wpml/ (二重URL!)
注: これは表示上のエラーであり、これらのリダイレクトがナビゲーションの問題を引き起こすことはありません
回避策
この問題は修正されました。 最新バージョンにアップデートするとお使いのサイトで問題が解決するため、この回避策はまだアップデートできない場合にのみ必要です。
作業を進める前に、必ずサイトの完全なバックアップを取得してください。
- …/wp-content/plugins/wordpress-seo-premium/classes/term-watcher.php ファイルを開きます。
- 「protected function get_target_url(」関数を探します。241行目付近にあります。
- 次を:PHP
protected function get_target_url( $tag, $taxonomy ) { // Get the term link. $term_link = get_term_link( $tag, $taxonomy ); // Return early if the term link is not a string, i.e. a WP_Error Object. if ( ! is_string( $term_link ) ) { return ''; } return str_replace( home_url(), '', $term_link ); }
- 次のように置き換えます:PHP
protected function get_target_url( $tag, $taxonomy ) { // Get the term link. $term_link = get_term_link( $tag, $taxonomy ); // Return early if the term link is not a string, i.e. a WP_Error Object. if ( ! is_string( $term_link ) ) { return ''; } // Extract the path to handle WPML subdomain URLs (matches post-watcher behavior). $url = wp_parse_url( $term_link ); if ( is_array( $url ) && isset( $url['path'] ) ) { return $url['path']; } return ''; }