Point subdomain to sub directory with htaccess

Enter the below into the .htaccess file. This will not perform a redirect, but will instead show the content of a sub directory at the specified host below. Modify the subdirectory and host parameters as necessary to fit your needs.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/subdirectory/
RewriteCond %{HTTP_HOST} subdomain.mywebsite.com$
RewriteRule ^(.*)$ subdirectory/$1 [L]

Leave a comment

Your email address will not be published. Required fields are marked *