Probably
RewriteRule ^([0-9]{6}).*$ templates/default/index.php?ref=$1
([0-9]{6})
was already correct, it captures the six digits
.*
matches any character afterwards.
$1
gets replaced by the contents of the first capture group ()
If you want to restrict the URL to match only if there are exactly six digits, then it should look like this (note the dash -
):
RewriteRule ^([0-9]{6})-.*$ templates/default/index.php?ref=$1
or matching the URL only if it is ending in .html
:
RewriteRule ^([0-9]{6})-.*?\.html$ templates/default/index.php?ref=$1
I suggest to read the mod_rewrite
documentation.
Also regular-expressions.info is great for learning regular expressions.