์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ ์‚ฌ์ด๋“œ๋ฐ”๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

Waiting for author

Reported for: WPML SEO 2.1.0

Topic Tags: Compatibility

Overview of the issue

When using the Yoast SEO Pro plugin, RegEx redirect rules do not work in the same way across different languages. There is a different behavior for the default language and the second language.

For example, if you create a redirection rule like ^/en/faq/(.+)$ to /en/support/$1, itย might not work as expected when trying to access it through http://example.com/en/faq/test/.

Workaround

Option 1

As a quick workaround you can create different rules.
Following the initial example:

  • ^/faq/(.+)$ redirects to /support/$1
  • ^faq/(.+)$ redirects to /en/support/$1

Option 2

Please, make sure of having a full backup of your site before proceeding.

  • Open …/wp-content/plugins/wp-seo-multilingual/classes/class-wpml-wpseo-redirection.php file.
  • Look for the line 34.
  • Replace this code:
    foreach ( $redirections as $redirection ) {
        if ( $redirection['origin'] === $url || '/' . $redirection['origin'] === $url ) {
            return true;
        }
    }
    
  • With:
    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;
    				}
    }
    

์‘๋‹ต 5๊ฐœ ๋Œ€์ƒ “Yoast SEO - Redirection RegEx Rules Differ Across Languages with WPML”

๋‹ต๊ธ€ ๋‚จ๊ธฐ๊ธฐ

์ฃผ์ œ์— ์ง‘์ค‘ํ•˜๊ณ  ๋‹ค๋ฅธ ์‚ฌ๋žŒ์„ ์กด์ค‘ํ•ด ์ฃผ์„ธ์š”. ์ด ๊ฒŒ์‹œ๋ฌผ๊ณผ ๊ด€๋ จ ์—†๋Š” ๋ฌธ์ œ์— ๋„์›€์ด ํ•„์š”ํ•˜๋ฉด ์ง€์› ํฌ๋Ÿผ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ฑ„ํŒ…์„ ์‹œ์ž‘ํ•˜๊ฑฐ๋‚˜ ํ‹ฐ์ผ“์„ ์ œ์ถœํ•˜์„ธ์š”.

๋‹ค์Œ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>