title: htaccess redirect to enother domain and language
body: <p>I need to write a rewrite rule to redirect from one domain to another.</p>
  
  <pre><code>   maindomain.com/en/ -&gt; secounddomain.com/en/
     maindomain.com/en/pagename.html -&gt; secounddomain.com/en/pagename.html
     www.maindomain.com/en/ -&gt; secounddomain.com/en/
     www.maindomain.com/en/pagename.html -&gt; secounddomain.com/en/pagename.html
     secounddomain.com -&gt; secounddomain.com/en/
     www.secounddomain.com -&gt; secounddomain.com/en/
  </code></pre>
  
  <p>and for secure (no back)</p>
  
  <pre><code>   secounddomain.com/pl/ -&gt; secounddomain.com/en/
     www.secounddomain.com/pl/ -&gt; secounddomain.com/en/
  </code></pre>
  
  <p>I try to do it like this but it doesn't work:</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} ^maindomain.com/en/$ [NC]
     RewriteRule ^(.*)$ http://www.secounddomain.com/en/$1 [r=301,L]
  
     RewriteCond %{HTTP_HOST} ^www.maindomain.com/en/$ [NC]
     RewriteRule ^(.*)$ http://www.secounddomain.com/en/$1 [r=301,L]
  
     RewriteCond %{HTTP_HOST} ^www.secounddomain.com/pl/$ [NC]
     RewriteRule ^(.*)$ http://www.secounddomain.com/en/$1 [r=301,L]
  
     RewriteCond %{HTTP_HOST} ^secounddomain.com/pl/$ [NC]
     RewriteRule ^(.*)$ http://www.secounddomain.com/en/$1 [r=301,L]
  </code></pre>
  
  <p>Best regards.</p>