- 상태
- 개발자 대기 중
- 보고된 제품
- WPML SEO 2.1.0
- 관련 플러그인/테마
- Yoast SEO
- 주제 태그
- Compatibility
문제 개요
Yoast SEO Pro 플러그인을 사용할 때 RegEx 리디렉션 규칙은 여러 언어에서 동일한 방식으로 작동하지 않습니다. 기본 언어와 보조 언어에서 다르게 동작합니다.
예를 들어 ^/en/faq/(.+)$를 /en/support/$1(으)로 리디렉션하는 규칙을 생성하면, http://example.com/en/faq/test/를 통해 액세스하려고 할 때 예상대로 작동하지 않을 수 있습니다.
임시 해결 방법
옵션 1
빠른 임시 해결 방법으로 다른 규칙을 생성할 수 있습니다.
초기 예제에 따르면 다음과 같습니다.
- ^/faq/(.+)$는 /support/$1로 리디렉션됩니다.
- ^faq/(.+)$는 /en/support/$1로 리디렉션됩니다.
옵션 2
계속 진행하기 전에 사이트의 전체 백업을 생성했는지 확인하세요.
- …/wp-content/plugins/wp-seo-multilingual/classes/class-wpml-wpseo-redirection.php 파일을 여세요.
- 34번째 줄을 찾으세요.
- 다음 코드를:
foreach ( $redirections as $redirection ) { if ( $redirection['origin'] === $url || '/' . $redirection['origin'] === $url ) { return true; } } - 아래 코드로 교체하세요:
foreach ( $redirections as $redirection ) { if($redirection['format'] == 'regex'){ // Ensure $url starts with /, if regex would need to check if string starts with this is needed. if(strpos($url, '/', 0) !== 0){ $url = '/' . $url; } // Lets use ~ as a regex delimiter instead of /, as we are matching a URL. preg_match('~' . $redirection['origin'] . '~', $url, $matches); if(count($matches) > 0){ return true; } } else if($redirection['origin'] === $url || '/' . $redirection['origin'] === $url){ return true; } }