RewriteCond %{HTTP_HOST} ^(.+)\.example\.com RewriteRule ^([^/]*)$ http://example.com/?name=%1&type=$1 [R,L]
"%1" means using the first capture group from RewriteCond, and $1 means the first capture group in the rule itself.
In your example, %1 will be "abc" and $1 will be a "book"
[^/]* means "match each character with no slash, 0 or more times
source share