Reputation: 143
I want to set a subdomain for all site users, like www.companyname.mydomain.com I would like to use htaccess for this.
when somebody requests www.companyname.mydomain.com it should redirect to myfile.php?name=companyname
How can I achieve this using an htaccess file ?
Thanks for the consideration.
Upvotes: 5
Views: 176
Reputation: 13691
Make sure this website is configured to respond to *.mydomain.com.
RewriteCond %{http_host} ^www.(\w+).mydomain.com [NC]
RewriteRule ^.*$ /myfile.php?name=%1 [L]
You might want to adjust ^.*$
, since this check will rewrite regardless of what comes after www.companyname.mydomain.com.
Upvotes: 1