I am a bit stuck with my htaccess... let me explain how I want it to work...

I have a wildcard subdomain, for example, demo1.domain.com, demo2.domain.com...
I want htaccess to take whatever the subpart of the domain is and pass it as a variable...

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_URI} !(/$|\.) 
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L] 

RewriteCond %{HTTP_HOST} !^www\.domain.org.uk
RewriteCond %{HTTP_HOST} ^(.+).domain.org.uk
RewriteRule ^([^/]*)$ http://domain.org.uk/app/index.php?id=%1 [P,L,QSA]

This works and I can get the variable ID... I then use the to query a database and get the users database details and settings etc and save them into Sessions...

Then I want to be able to redirect them to http://demo1.domain.com/app/login/

Where it then loads /app/login.php and also passed any variables... such as /app/login/?cmd=update = /app/login.php?cmd=update..

However I can't get the latter part working... any help would be amazing!