To redirect a subdomain to a subdirectory, use following .htaccess code.
RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com RewriteRule ^(.*)$ subdomains/%1/$1 [L,NC,QSA]
Redirect Subdirectory to Subdomain
RewriteEngine on RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ RewriteRule ^/?subdomain/(.*)$ https://subdomain.example.com/$1 [R=301]
See htaccess
Leave a Reply