Hi, I would like to ask regarding creating a subdomain automatically after signup on a site. example after registration i have my personal url link like http://myusername.mywebsite.com then when i type that url it will automatically redirect in login form a mywebsite.com. I know it can be done in htaccess but i can't figure it out. Please help thanks.
First things is that you need to have wild card subdomains enabled in the server, and a CNAME record * pointing to the root of the site or somewhere on the site. After that you may just take the myusername part from the HTTP_HOST variable using some algorithm to get the subdomain http://myusername.mywebsite.com or simply write a rule to get the subdomain name in a variable. With subdomain pointing to the same script file, we can program it using conditions for the main domain or the subdomain.
thanks for the reply, i have created a subdomain on my cpanel something *.mydomain.com , now any subdomain redirect to the site, how can i filter that subdomain and redirect to url something like http://mydomain.com/index.php?do=login. Thanks
You can do that using simple php. Create a php function to get the subdomain name from subdomain.domain.com. If the subdomain is empty or www, do not redirect, else do the redirect.