First of all your DNS-Entry needs to have a "catch-all-subdomains" root entry (like "*.example.com"). Now subdomains have to be defined in the Configuration of the webserver. I guess you are running on Apache. I don't know exactly but probably it is possible to define subdomains in the .htaccess file in your webroot. Otherwise you have to use the httpd.conf of the server, which might not accesible to you, if you are on a shared hosting environment. Your PHP-Script has to add a VirtualHost entry to either one of these files: <VirtualHost *> ServerName subdomain.domain.com DocumentRoot /home/httpd/htdocs/subdomain/ </VirtualHost> Just some quick thoughts... Kind regards, Hans
Probably experimenting with Rewriting rules in the .htaccess file could work... Edited: Try setting up your subdomain like this in the .htaccess file: RewriteCond %{HTTP_HOST} subdomain.example.com $ [NC] RewriteCond %{REQUEST_URI} !/subdomain_directory/ RewriteRule ^(.*)$ subdomain_directory/$1 [L]
Try adding his to the top of your .HTACCESS file: Options +FollowSymLinks Then create symbolic links to the directories you want to make subdirectories by running the 'ln' *nix command. You can use the functions at : http://www.php.net/exec for this. Thomas
Is this a dedicated server or are you on a host? Which host would be helpful as well? It's possible you will need the assistance of your web host.