I am using Apache/PHP to aid shorlinks to documents and I am getting challenge with the Regex to redirect properly.

My links take the type of 8 letters/amounts, something similar to '1abc45fd', I must ask them to redirect to /shortlink.php?link=1abc45fd but it is simply not working properly. I am while using following expression: "RewriteRule ^([a-zA-Z0-9]+)$" during my .htaccess file but that redirects all Web addresses, not only ones which are only 8 chars. How do i customize the rule to limit to exactly matching the 8 chars?

Thanks ahead of time.

RewriteRule ^([a-zA-Z0-9]{8})$ shortlink.php?link=$1

You might want to acquaint yourself with Regular Expressions syntax more, I discovered this Regex Reference page to become a nice beginning.

RewriteRule ^([a-zA-Z0-9]{8})$

EDIT: Aistina beat me into it