RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.localhost RewriteRule (.*) http://localhost/foo.php?id=$1 [P] If [P] is used, "nothing happens", if [R] is used I get at least info from the script foo.php, even though I am redirected.