如何为动态生成的链接重写URL

I have created a small link which is dynamically generated. When i click on that link which will create a URL like this

http://localhost/store/user.php?id=12

if i give this url

http://localhost/store/user/12

which will produce the same out put which i want to see

What i want to do is that if i click on dynamically generated link which should produce

 http://localhost/store/user/12 

this url instead of this

http://localhost/store/user.php?id=12

how can i do this

.httaccess file is this

# Enable Rewriting
RewriteEngine on

# Rewrite user URLs
#   Input:  user/NAME/
#   Output: user.php?id=NAME
RewriteRule ^user/(\w+)/?$ user.php?id=$1
RewriteRule ^store/user/(\w+)/?$ store/user.php?id=$1