Thank you, Markus!
Just in case others run into the same problem, here's the solution to the problem:
RewriteCond %{HTTP_HOST} ^dev\.example\.com$
RewriteRule (.*) $1 [E=TYPO3_CONTEXT:Development]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule (.*) $1 [E=TYPO3_CONTEXT:Production]