Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can redirect all subdomains to the www folder using the following code in your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/%1/$1 [L,R=301]

This code will redirect any subdomain (except for www) to the www folder with the subdomain name added as a directory. For example, test.example.com would be redirected to www.example.com/test/.