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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.