I am trying to make use of .htaccess within the root folder of the Ubuntu/Apache2 server to be able to mask a subdomain to subfolder and that i keep obtaining a 500 Internal Error. I understand that I am doing something stupidly wrong which is some silly error leading to the issue. I have checked all the similar threads on SO an internet-based and whenever I attempt their move the 500 continues.

Here's my code.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^admin\.mydomain\.com.*$
RewriteRule (.*) intranet/$1 [L]

What I wish to occur is when a person visits admin.mydomain.com they'll obtain the items in the folder admin.mydomain.com/intranet/ however their URL bar it's still admin.mydomain.com. Any idea what I am doing wrong?

Additionally, a few of the threads online spoken about potential problems with this particular system. Is the easiest way to do this hiding, must i be utilising a vhost setup?

The rewrite rule should work, although I'd most likely write

RewriteEngine on
RewriteBase / #omit if in a <Directory> or .htaccess
RewriteCond %{HTTP_HOST} =admin.mydomain.com
RewriteRule ^(?!intranet/).* intranet/$0

Now, you might like to check you Apache error log. It'll most likely let you know exactly what the error is. My prediction is you didn't enable mod_rewrite in httpd.conf.