每个用户使用.htaccess的子域域

I am using Amazon Ec2. I am not professional in .htaccess , i have referred following .htaccess

RewriteCond %{HTTP_HOST}    ^([\w-]+).example.com$
RewriteCond %{REQUEST_URI}  !^/example.com/
RewriteRule ^(.*)$          /example.com/$1?subdomain=%1 [LAST,QSA]

when i try to execute this username.example.com to example.com/subdomain?id=username

I am using EC2 amazon server.

1st issues is if i am trying to execute username.example.com then this domain is not getting resolved.

2nd issue the above htaccess is not working for me . If any one could solve this will be helpful

You cannot do this using .htaccess file, you need to setup a wild card virtual host and then rewrite it to the URL you need.

This information might be useful, you can also refer to this question.