I have a sitename.net and in a root directory i have .htaccess and index.php .htaccess is:
FallbackResource /index.php
so basically as it's empty site (no sub directories, no files etc...) I will get a fallback to index.php which contains this:
$path = ltrim($_SERVER['REQUEST_URI'], '/');    // Trim leading slash(es)
$elements = explode('/', $path);                // Split path on slashes
echo "Domain is: $domain <br>";
if(empty($elements[0])) {                       // No path elements means home
    echo "ShowHomepage()";
} 
else switch(array_shift($elements)) {             // Pop off first item and switch
    case 'tests':
      echo "First is test";
    case 'sample':
      echo "First is sample";
    default:
        header('HTTP/1.1 404 Not Found');
        Show404Error();
}
my problem is that when visitor enters: https://username.sitename.net/tests/test1 I get error as subdomain doesn't exist... When I go to "https://sitename.net/tests/test1" i get what I want but I need username as a variable as well.
Should I first do rewrite in .htaccess so it translate https://username.sitename.net/tests/test1 as https://sitename.net/username/tests/test1 and than redo index.php so it pickup a first array element as username or there is another option ?
Can somebody help me out ?
------------- EDIT ----------------
I've ended up pointing A record *.sitename.net to server IP I've changed .htaccess so it's:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(.*)\.sitename\.net
RewriteRule ^(.*)$ subdomains/%1/$1 [L,NC,QSA]
FallbackResource /index.php
...and still getting 404 error... still can't get: https://username.sitename.net/tests/test1 to act like https://sitename.net/username/tests/test1 so index.php will do it stuff...
 
     
    