I am trying to use the following scenario to create to give registered users there own subdomain to the site. I do not want to add DNS records for every user but if user jon signs up I would like him to see the URL of jon.website.com. It seems that this is possible from other questions that I have read up on.
However my implementation and lack of understanding is holding me up. Here is what I have done so far.
Added DNS wildcard A record for domain
*.website.com --> IP of website ex. 12.2.3.4
Added the following code to .htaccess file in www.website.com/application/
<VirtualHost *:80>
ServerName server.website.com
ServerAlias *.website.com
UseCanonicalName Off
</VirtualHost>
Find subdomain with PHP
preg_match('/([^.]+)\.example\.org/', $_SERVER['SERVER_NAME'], $matches);
if(isset($matches[1])) {
$subdomain = $matches[1];
}
How I would see this working is, when the user signs up, a directory with the subdomain name is created as in www.website.com/application/subdomainName/ -- I can handle this no prob -- Then on successful login the user is then directed to www.website.com/application/jon/
Am I headed the right direction on this? If yes then how do I get from where I am I where I need to go? This one is quite a bit above my pay grade! Thanks for any advise!