Fix #1239.

rfind up to the beginning of the resource key, to allow <prefix>/<resource_name>/<resource_name>/ in case <resource_name> is a valid identifier