2022-04-26, 02:35:40
Had a problem with activating GSCANONICAL and using a language dropdown (utilizing return_i18n_setlang_url($lang)) at the same time. The "setlang" url parameter vanished at redirecting when GSCANONICAL was set to 1.
I made a small, ugly hack in index.php to fix this for my site.
Original:
I replaced this with:
Of course only useful when the parameter name "setlang" was not changed.
This works for me.
But I still wonder whether there might be a better solution without hacking index.php.
I made a small, ugly hack in index.php to fix this for my site.
Original:
PHP Code:
if (getDef('GSCANONICAL',true)) {
if ($_SERVER['REQUEST_URI'] != find_url($url, $parent, 'relative')) {
redirect(find_url($url, $parent));
}
}
I replaced this with:
PHP Code:
if (getDef('GSCANONICAL',true)) {
$psetlang = (isset($_GET['setlang']))? '?setlang='.$_GET['setlang'].'' : '';
if ($_SERVER['REQUEST_URI'] != find_url($url, $parent, 'relative').$psetlang) {
redirect(find_url($url, $parent).$psetlang);
}
}
Of course only useful when the parameter name "setlang" was not changed.
This works for me.
But I still wonder whether there might be a better solution without hacking index.php.