Prepend a country code to the beginning of all URLs in Wordpress
<p>I have a WP question hoping someone can point me in right direction. </p>

<p>I have a Wordpress site that allows users to switch regions — they still see the same pages/menus but the content is different depending on the region they selected. </p>

<p>Now, I would like to display the region at the root of the URL, for example:</p>

<p><a href="http://website.com/au/hello-world/" rel="nofollow noreferrer">http://website.com/au/hello-world/</a></p>

<p><a href="http://website.com/us/hello-world/" rel="nofollow noreferrer">http://website.com/us/hello-world/</a></p>

<p>Essentially the first part of the URL will do nothing other than indicate the country they are currently viewing.</p>

<p><a href="https://stackoverflow.com/questions/9715704/how-to-make-wordpress-permalinks-ignore-custom-url-rewrite">I found this question which was similar</a>, but OP ended up using a plugin which I want to avoid. </p>

<p>I see a lot of info about using the query_vars filter to the end of a URL as a way of passing parameters in a clean way, but they all seem to assume you want the param to be at the end of the URL rather than the beginning. </p>