Redirect wildcard subdomains to subdirectory, without changing URL in address bar
snippet in htaccess

Redirect wildcard subdomains to subdirectory, without changing URL in address bar

user4496

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.website\.com$
RewriteCond %{HTTP_HOST} ^(\w+)\.website\.com$
RewriteCond %{REQUEST_URI}:%1 !^/([^/]+)/([^:]*):\1
RewriteRule ^(.*)$ /%1/$1 [QSA]