I’m working with two plugins with a different language query string setup. The language plugin itself works with mydomain.com/?lang=english (polylang plugin), the other plugin needs to retrieve mydomain.com/?language=english.
How should I rewrite the url so both are working correctly? I’ve tried the following:
function languagerewrite() {
//$language = get_query_var('lang', 1);
//get_query_var not working, yet 'lang' is registered Why?
if(isset($_GET["lang"])) {
$language = $_GET["lang"];
echo esc_url(add_query_arg( 'language', $language ));
}
}
add_action('init', 'languagerewrite', 10, 0);
This will echo the following:
?lang=english&language=english which should work, although I need to rewrite that to a nice url.
How can use the printed url? And is this the best way to do this in php or should I rewrite this in htaccess? Thanks.
Use such htaccess
To try, add R – [R,L] to see redirect in browser address tab