Subdomain setup


#1

Hi - I would like to achieve the following:

If I have a domain "www.mydomain.com". This page is served from /var/website for example.
Now I want a wildcard subdomain which I achieved with dns editor and a cpanel wildcard subdomain and I pointed it to /var/website/subfolders.

It works. Now I want that user1.mydomain.com must open /var/website/subfolders/user1 IF it exists.
And all is done with a wildcard, so I don't truly have to create the folders specifically inside the /var/website/subfolders.

I tried the following in .htaccess in the root of /var/website/subfolders:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*).mydomain.com
RewriteCond %{HTTP_HOST} !^(www). [NC]
RewriteRule ^(.*)$ http://%1\.mydomain.com/%1/$1 [P,NC,QSA]

But instead of giving me a silent rewrite like this: user1.mysite.com it gives me user1.mysite.com/user1

Is there any way this could be achieved? I want to have different owncloud ones for different users dynamically. So if the folder doesn't exist, then the index.php from the /var/website/subfolders/ will handle a cloning and a database setup for that user.

Is there a way to achieve this using a .htaccess rule I am missing?
Thank you in advance.