0

I have two domains:

domain.com and domain.it

Need to add a script/code to the language button so it redirects from all of the pages with English language to the same pages at Italian domain just replacing domain extension such as:

domain.com/text.html to domain.it/text.html

or

domain.com/text1.html to domain.it/text1.html

or

domain.com/text2.html to domain.it/text2.html

and etc.

How to go about it?

Timo Yur
  • 3
  • 2

1 Answers1

0
<button onclick="redirect()">Italian Version</button>

<script>
function redirect()
{
  var currentUrl = window.location.href;
  var newUrl = currentUrl.replace(".com", ".it");
  window.location.replace(newUrl);
}
</script>