Stack Overflow generates rewrite URLs,
so i need to know how i can do it like Stack Overflow?
http://stackoverflow.com/questions/9168364/how-to-rewri
You need to tweak your regex a bit by making trailing slash optional. Use this rule:
RewriteRule ^([0-9]+)(?:/([^/]*))?/?$ ./cat.php?id=$1&title=$2 [L,NC]