Htaccess rewrite subdomain and requests uri

.htaccessrewrite

Having trouble with a rewrite condition within my htaccess. I need to redirect the request from a subdomain. However, there are three subdomains for each language: en.foo.com, es.foo.com, www.foo.com. If they have a request they must persist the according subdomain.

E.g:

Requested:
fdsfds.foo.com/test

Desired:
www.foo.com/test

Currently:
www.foo.com

.htaccess file:

# BEGIN .net to .com redirect
RewriteEngine On
RewriteCond %{HTTP_HOST} foo.net$ [NC]
RewriteRule ^(.*)$ http://www.foo.com/$1 [R=301,L]
# END .net to .com redirect

# BEGIN force www on non-www requests
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# END force www on non-www requests

# BEGIN .net to .com redirect (english)
RewriteCond %{HTTP_HOST} ^en\.foo\.net$ [NC]
RewriteRule ^(.*)$ http://en.foo.com/$1 [R=301,L]
# END .net to .com redirect (english)

# BEGIN .net to .com redirect (spanish)
RewriteCond %{HTTP_HOST} ^es\.foo\.net$ [NC]
RewriteRule ^(.*)$ http://es.foo.com/$1 [R=301,L]
# END .net to .com redirect (spanish)

# BEGIN .net to .com redirect (spanish)
RewriteCond %{HTTP_HOST} ^www\.foo\.net$ [NC]
RewriteRule ^(.*)$ http://www.foo.com/$1 [R=301,L]
# END .net to .com redirect (spanish)

# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^es\. [NC]
RewriteCond %{HTTP_HOST} !^en\. [NC]
RewriteRule ^ http://www.foo.com/ [L,R=301]

Best Answer

Well, I think you just need to modify the last RewriteRule, which redirects every other request (i. e. the ones that do not start with es or en or www) to http://www.foo.com/. Could you try something like this instead:

RewriteRule ^(.*)$ http://www.foo.com/$1 [L,R=301]

and please let me know if it does the right thing.