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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With