Create a permalink for a post’s attachments

You could achieve that by adding a rewrite endpoint via add_rewrite_endpoint.

This post from a WordPress developer has a good explanation of how they work.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)