Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将查询添加到URL范围_Url_Translate - Fatal编程技术网

将查询添加到URL范围

将查询添加到URL范围,url,translate,Url,Translate,我想将查询添加到包含/en/的所有URL中 总是需要 子URL,如example.nl/en/uncategorized/nieuws/始终需要是example.nl/en/uncategorized/nieuws/#googtrans(nl | en) 可能有用:无论何时/en/在URL中,我都将li class=“lang en”作为“lang en active”,但我不知道这是否有帮助 目标是在加载英文页面时自动运行谷歌翻译 通过添加以下内容尝试.htaccess: RedirectMa

我想将查询添加到包含/en/的所有URL中

总是需要

子URL,如example.nl/en/uncategorized/nieuws/始终需要是example.nl/en/uncategorized/nieuws/#googtrans(nl | en)

可能有用:无论何时/en/在URL中,我都将li class=“lang en”作为“lang en active”,但我不知道这是否有帮助

目标是在加载英文页面时自动运行谷歌翻译

通过添加以下内容尝试.htaccess

RedirectMatch^/en/(*)$example.nl/en/$1#googtrans(nl|en)

但我得到了太多的重定向错误。也尝试使用jquery,但我的代码对url本身不起作用:

$(document).ready(function () { 
    $('li.lang-en.active') { 
        $(this).attr("href", $(this).attr("href") + "#googtrans(nl|en)”); 
    }) 
});
经过多次尝试和错误后(无法通过.htaccess工作),我通过以下方法解决了此问题:

<script>
if (document.location.pathname.indexOf("/en/") == 0) {
    window.location.hash = "#googtrans/nl/en";
}
</script>

if(document.location.pathname.indexOf(“/en/”)==0){
window.location.hash=“#googtrans/nl/en”;
}

到目前为止你尝试过什么吗?徒劳的努力。通过添加RedirectMatch^/en/(.*)$example.nl/en/$1#googtrans(nl | en)尝试过.htaccess,但我收到了太多重定向错误。也尝试过jquery,但我的代码对url本身不起作用:$(document).ready(函数(){$('li.lang en.active'){$(this).attr(“href”),$(this).attr(“href”)+“#googtrans(nl|en);});