You are correct. All you need is a little PHP code. What your host has set up is called psuedo sub domains as it simulates real sub domaining but no DNS or virtual server alterations are needed. Your host has set up a wildcard DNS entry (*.domain.com) and virtual server which point all sub domains into your root directory. Here's how to use it. Make a directory in your root folder called games and put all your games web pages in there. Name each one as follows: 'gamename.php'. Now put the following code right at the top of your 'index.php' file in your root directory and everything will work as you hoped.
PHP Code:
<?php
$host = $_SERVER['HTTP_HOST'];
$domain = 'domain.com'; //alter to suit
$games_directory = '/games/'; //alter to suit
if(($host != $domain or $host != 'www'.$domain) and list($game) = spliti('\.', $host) and file_exists($games_directory.$game)){
include($games_directory.$game.'.php');
exit();
}else{
// display default root directory contents (index.php) as this is the domain root file
}
?>
Bookmarks