How to redirect from a subdomain to a subfolder using .htaccess

You need to change your RewriteRule to include the new domain you’re trying to redirect too, otherwise it will treat the beginning / as a new path on the current domain.

Options +FollowSymLinks 
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com
RewriteRule ^(.*)$  [R=301]

A second solution that might work for you

Options +FollowSymLinks 
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www)\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com [NC]
RewriteRule (.*)  [R=301,L]

Skriv et svar