there is a redirect I tried to do on my site, but I am quite confused in it. First of all, I have SSL installed on the site and I use non-www domain redirect. In the .htaccess file below 301 redirect to https://. If I need to summarize the situation, domainame.com is directing to the default https://domainname.com/tr/ and https://domainname.com/en/ I have 2 languages in my rop and there are confusion in the cannonical part, thank you if you can help. I'm using WP and polylang
.htaccess file
#Jet pack broken Stats
AllowOverride FileInfo Limit
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Header always set Content-Security-Policy "upgrade-insecure-requests;"
this code is in functions.php file
add_filter( 'pll_rel_hreflang_attributes', 'filter_pll_rel_hreflang_attributes', 10, 1 );
// Define the pll_rel_hreflang_attributes callback.
function filter_pll_rel_hreflang_attributes( $hreflangs ) {
foreach ( $hreflangs as $lang => $url ) {
if ( $lang === 'en' ) {
printf( '<link rel="cannonical" href=”http://domainname.com/en/” />');
printf( '<link rel="alternate" href="%s" hreflang="%s" /><!-- country code en-US-->' . "\n", esc_url( $url ), esc_attr( 'en-US' ) );
}
elseif ( $lang === 'tr' ) {
printf( '<link rel="cannonical" href=”http://domainname.com/tr/” />');
printf( '<link rel="alternate" href="%s" hreflang="%s" /><!-- country code tr-TR-->' . "\n", esc_url( $url ), esc_attr( 'tr-TR' ) );
}
}
return $hreflangs;
};