How to Redirect Your Primary Domain to a Subdirectory

Programming, error messages and sample code > IIS Rewrite
 
Simply create a new .htaccess file in your site root folder and place below code in it
 
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/subdirectory/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /subdirectory/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
RewriteRule ^(/)?$ subdirectory[L]
Making sure to substitute example.com for your primary domain and subdirectory for the subdirectory to which you are redirecting the domain.