title: Wordpress Rewrite Rule to enforce default lang code in URL
body: <p>I am running a WP Blog with qtranslate. It allows me to create posts in multiple languages.</p>
  <p>1 . Example URL without qtranslate:</p>
  <ul>
  <li><a href="http://www.mysite.com/post1" rel="nofollow noreferrer">www.mysite.com/post1</a></li>
  </ul>
  <p>2 . Example URL with localized content:</p>
  <ul>
  <li><p><a href="http://www.mysite.com/**en**/post1" rel="nofollow noreferrer">www.mysite.com/**en**/post1</a> (english - my default and fallback)</p>
  </li>
  <li><p><a href="http://www.mysite.com/**de**/post1" rel="nofollow noreferrer">www.mysite.com/**de**/post1</a></p>
  </li>
  </ul>
  <p>Unfortunately search engines etc. still remember my old links (1.) and these are still access-able. So &quot;www.mysite.com/post1&quot; now shows my english content without a redirect. But what it <em>should</em> do is to 301 users to &quot;www.mysite.com/en/post1&quot;.</p>
  <p>So now I would need a rule that basically checks if there is /<strong>en</strong>/post1 or a /<strong>de</strong>/post1 in the URL and otherwise redirect to the fallback /<strong>en</strong>/post1 URL. There is one exception because &quot;/<strong>shop</strong>&quot; is a real subdirectory and does not need to be preceeded by language information.</p>
  <p>-- UPDATE --</p>
  <p>I did it!!! That was actually fun but took me quite a while to figure out.</p>
  <pre><code>RewriteRule ^$ en [R=301,L]
  RewriteRule ^([a-z]{2})/{1}$ $1 [R=301,L]
  RewriteRule ^([a-zA-Z0-9\-\_]{3,})(/|$)$ en/$1 [R=301,L]
  </code></pre>
  <p>There are probably better ways to do this but it does the trick. Thanks everyone for the initial help!</p>