How to add 2 variable rewrite rule?

You’ll need to write a rewrite rule to parse the URL and pull out the value of gallery-name and gallery-item-name. This will be tricky as there is nothing to distinguish your proposed URL structure from a hierarchical page structure. If you can throw in something that is always the same for all gallery URLs like /gallery/<gallery-name>/<gallery-item-name>/.

Once you have a rewrite rule in place you can hook into the template_include filter, check if your two variables are set and then tell WordPress to include your gallery template.

Shiba Shake has a good tutorial on galleries with custom permalinks
http://shibashake.com/wordpress-theme/wordpress-permalink-add