.htaccess RewriteRule参数

I have a simple .htaccess file:

RewriteEngine on
RewriteRule ^(.+)-([0-9]+)\.html$ book.php?title=$1&id=$2
RewriteRule ^(.+)\.html$ search.php?search=$1

If a users enter "php-for-dumies-10.html" it going to be served as "book.php?title=php-for-dummies&id=10". That works fine.

If a user enters "phpbook.html" it going to be served as "search.php?search=phpbook". That works fine too.

The problem is if a user enters "directory/php-for-dumies-10.html" (adding a directory in the URL) insted of getting "book.php?title=directory/php-for-dumies&id=10" as expected, i'm getting "search.php?search=book.php/php-for-dumies-10"

Why does the second RewriteRule execute instead of the first one? Is because i'm adding a slash? And more important, where is the "book.php/php-for-dummies-10" parameter is coming from?

Thank you for any help.

RewriteEngine on
RewriteRule ^(.+)-([0-9]+)\.html$ book.php?title=$1&id=$2 [L]
RewriteRule ^(.+)\.html$ search.php?search=$1 [L]

Actually, both rewrites are executing. By adding an [L] flag it prevents subsequent rules from executing. This should force only the first rule to execute if its a match.