I am using CakePHP framework 2.2.2
I want to create personalize URL for user if user enter username=pragnesh
then they can access my site like http://pragnesh.example.com
same as in blinksale.com
My URL http://example.com/test/users/front_home
I want to access it as http://test.example.com/users/front_home
My URL: http://example.com/test/setting/pages
can be access as: http://test.example.com/setting/pages
any URL: http://example.com/test/xxxxx/xxxxx
can be access as: http://test.example.com/xxxxx/xxxxx
OR
URL http://example.com/users/front_home?site=test
I want to access it as http://test.example.com/users/front_home
My URL: http://example.com/setting/pages?site=test
can be access as: http://test.example.com/setting/pages
any URL: http://example.com/xxxxx/xxxxx?site=test
can be access as: http://test.example.com/xxxxx/xxxxx
My question may be duplicate of https://stackoverflow.com/questions/20328636/my-cakephp-2-2-site-not-working-on-subdomain but there is no answer posted
I have tried below code in \app\webroot\.htaccess
https://stackoverflow.com/questions/5649890/htaccess-subdomai-part-2
RewriteCond %{QUERY_STRING} !^([^&]*&)*site=[^&]+
RewriteCond %{HTTP_HOST} !^www\.example.com
RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]+)\.example.com
RewriteRule ^([^\.]*).php$ /$1.php?user=%1 [QSA,L,R]
https://stackoverflow.com/questions/25938781/url-rewrite-for-subdomain
# capture first part of host name
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$ [NC]
# make sure site= query parameter isn't there
RewriteCond %{QUERY_STRING} !(^|&)site= [NC]
# rewrite to current URI?site=backererence #1 from host name
RewriteRule ^ %{REQUEST_URI}?site=%1 [L,QSA]
but both not working for me.
my root .htaccss file is
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
\app\.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
\app\webroot\.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Virtual Host in httpd.conf
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs/bsale"
ServerName example.com
ServerAlias *.example.com
<Directory "C:/xampp/htdocs/bsale">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
HOST FILE
127.0.0.1 example.com
127.0.0.1 *.example.com