tags:

views:

36

answers:

1

I am trying to redirect something like this

sub-domain.domain.com/directory to domain.com/directory

I tried Redirect 301 / domain.com/directory [htaccess file placed in sub-domain] it works fine for the sub-domain but won't work for the directory within the sub-domain.

Can somebody help me with what should be the content of .htaccess file ?

Thanks.

A: 

If you simply want to re-direct all requests from xxx.domain.com/yyy to www.domain.com/yyy you can use:

RewriteCond %{HTTP_HOST}   !^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://www.domain/com/$1 [L,R]

NB: You'll need to ensure that the rewrite engine is on first, etc.

Updated..

If you just want a 301, change the [L,R] on the last line to [L,R=301]

middaparka