RewriteRule ^/(\d+)/?.*$ /view.php?id=$1 [L]
Это перезапишет http://host/1234/some-text
и http://host/1234
в http://host/view.php?id=1234
.
Подробное объяснение:
^ -- matches at the start of the string
( -- start match group
\d+ -- match one or more digits
) -- end match group
/? -- match 0 or 1 slash
.* -- match any character 0 or more times
$ -- matches at the end of the string
Посетите регулярные-выражения.info для полного руководства по регулярному выражению.