title: Magento multi language rewrites SEO fix?
body: <p>I have made a website in with Magento in one language 2 years ago and now I would like to add another language.
  My actual structure is like that </p>
  
  <ul>
  <li>example.com/category/</li>
  <li>example.com/about.html</li>
  <li>example.com/product.html</li>
  </ul>
  
  <p>and I would like to obtain a structure like this:</p>
  
  <ul>
  <li>example.com/lang1/category/</li>
  <li>example.com/lang1/about.html</li>
  <li>example.com/lang1/product.html</li>
  <li>example.com/lang2/category/</li>
  <li>example.com/lang2/about.html</li>
  <li>example.com/lang2/product.html</li>
  </ul>
  
  <p>This is not a big deal since Magento allowes me us to do that simply logging in the backend ->System -> Configuration -> Web -> Add store code to Urls (YES)</p>
  
  <p>I can't do this setting right now because before that I need to fix and do rewrites from the first structure to the new one.</p>
  
  <ul>
  <li>example.com/everything_without_the_/lang1/_path to a permanent </li>
  <li>example.com/lang1/everything</li>
  </ul>
  
  <p>I need for example that the urls from the backlinks from posts from the socials and other webistes won't get a 404 error but will automatically be redirected with a 301 redirection to the equivalent page in the new structure.</p>
  
  <p>So I would like to add a script like this in the natural language:</p>
  
  <pre><code>rewrite permanently all the urls which ends not with /lang1/ or /lang2/ to urls with the prefix /lang1/
  </code></pre>
  
  <p>I know that I could manually add rewrite rules with this schema in the Magento backend but I would prefer to know if it is possible to batch this directly from the database or with some script in the .htaccess or index.php and above all which one between these solutions will have a less negative impact in SEO and SERP. </p>
  
  <hr>
  
  <p>I've found a solution</p>
  
  <p>Hi I've found a solution:</p>
  
  <pre><code>    RewriteCond %{HTTP_HOST} ^(.)?example.com$ [NC] 
      RewriteCond %{REQUEST_URI} !^/it/
      RewriteCond %{REQUEST_URI} !^/en/
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ /it/$1  [R=301,L]
      RewriteCond %{HTTP_HOST} ^(.)?example.com$ [NC]
      RewriteRule ^(/)?$ it/index.php [L]
  </code></pre>
  
  <p>at a first look works, but I not guarantee. 
  I hope this will help
  Cheers</p>