Last updated on November 25, 2022
In this post, I want to explain how to redirect the subdomain to a subfolder with .htaccess. I implemented this for demos.arjunphp.com,lab.arjunphp.com and downloads.arjunphp.com I hope it is useful for you.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^demos\.arjunphp\.com$
RewriteCond %{REQUEST_URI} !^/demos/
RewriteRule (.*) /demos/$1
RewriteEngine On
RewriteCond %{HTTP_HOST} ^lab\.arjunphp\.com$
RewriteCond %{REQUEST_URI} !^/lab/
RewriteRule (.*) /lab/$1
RewriteEngine On
RewriteCond %{HTTP_HOST} ^downloads\.arjunphp\.com$
RewriteCond %{REQUEST_URI} !^/downloads/
RewriteRule (.*) /downloads/$1
That’s it.