Posts

Showing posts from January 18, 2013

create subdomains using htaccess

Its very quick and easy. Here we go You need to create a wildcard domain on your DNS server *.website.com  Then in your vhost container you will need to specify the wildcard aswell *.website.com - This is done in the ServerAlias DOCs  Then extract and verify the subdomain in PHP and display the appropriate data Here we go in some detail. Create a wildcard DNS entry -  In your DNS settings you need to create a wildcard domain entry such as *.example.com. A wildcard entry looks like this:  *.example.com.   3600  A  127.0.0.1 Include the wildcard in vhost -  Next up in the Apache configuration you need to set up a vhost container that specifies the wildcard in the ServerAlias DOCs directive. An example vhost container: <virtualhost> ServerName server.example.com ServerAlias *.example.com UseCanonicalName Off </VirtualHost> Work out which subdomain you are on in PHP - Then in your PHP scripts you can find out the domain by looking in the $_SERVER super g