Adding a string (subdomain) to the front of URL with Javascript or PHP
<p>I've been searching but couldn't find much info on this.</p>

<p>Basically, I'm building a (PHP based) website, and for my own language switching implementation I need to have buttons that I can click and it would redirect to the exact same page in the selected language. For example: <a href="http://example.com/page1?param1" rel="nofollow">http://example.com/page1?param1</a> to <a href="http://es.example.com/page1?param1" rel="nofollow">http://es.example.com/page1?param1</a>.</p>

<p>Is there any way to do this with javascript or php?</p>

<p>Thanks!</p>