all subdomains redirect to one subdomain

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pedroz
Forum Commoner
Posts: 99
Joined: Thu Nov 03, 2005 6:21 am

all subdomains redirect to one subdomain

Post by pedroz »

Need to redirect the all sub-domains, except en.domain.com
to en.domain.com

Like
www.domain.com/en/ -> en.domain.com
www.domain.com/en/test -> en.domain.com/test
www.domain.com/en/dir/index.htm -> en.domain.com/dir/index.htm

domain.com/en/ -> en.domain.com
domain.com/en/test -> en.domain.com/test
domain.com/en/dir/index.htm -> en.domain.com/dir/index.htm


What is wrong with the following code in .htaccess?

RewriteEngine on
RewriteCond %{HTTP_HOST} !^en.* [NC]
RewriteRule ^/en/(.*) http://en.domain.net/$1 [L,R]
Post Reply