views:

43

answers:

1

Hi all

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.

+1  A: 

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.

Fabian
how can I configure my website in such a way that respond to *.mydomain.com ? I am using cpanel in server
milan
Dont have any experience configuring apache, I guess thats a question worth asking on serverfault.com.
Fabian