Step 1: copy zf2 library (i.e ZEND folder inside zendframework download) to the root folder of your host i.e. after copy it looks like this(in my case) /home/username/zf2lib/ZEND (any location not accessible by public)
Step 2: edit .htaccess
#SetEnv ZF2_PATH /home/username/zf2lib
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
Step 3: edit init_autoloader.php to point to zf2 library, in this we have two option
1. if your host support SetEnv tag in .htaccess then simply uncomment the first line in the above .htaccess (mostly shared host don't provide these option, especially in my case) if the option 1 is not possible then you have to edit the init_autoloader.php file as below
/*$zf2path = false;
if(getenv('ZF2_PATH')){ //support for ZF2_PATH environment variable or git submodule
$zf2path=getenv('ZF2_PATH');
}elseif(get_cfg_var('zf2_path')){ //support for zf2_path directives value
$zf2path=getcfg var('zf2_path');
}elseif(is_dir('vendor/ZF2/library')){
$zf2path='vendor/ZF2/library';
}*/
$zf2path='/home/username/zf2lib';//(add this line)
Comment out from line 24 to 32, this code is responsible for various option to init the zend library, in our case we know where zf2 lib are loaded, so we are going to hard code the path, add line 33 and change username to your host user name.
Final step: copy all this content to your sub domain folder and access the site with subdomain.domain.com it all works well for me, hope it work for you too, good luck!