Q:

Subdomain does not work after .htaccess rewrite

My problem is a little hard to explain but I'll try...
I have a php website (www.mypage.com) on a web hotel that provides several services. One of many is a photo gallery. The standard url for the gallery is gallery.mypage.com. So far so good!
Recently I used this guide to make the website SEO friendly (search engine optimised): http://www.desiquintans.com/cleanurls 
and it works fine, but since I rewrite the urls in the .htaccess file, the subdomain of "gallery" does no longer work.
The web hotel support don't want to help or they don't know how to fix it. Do you guys know if there is a way to tamper with the .htaccess file like I have done and still be able to access the subdomain?
This is the .htaccess file. The first two lines was a try to fix this but it didn't work.
RewriteCond %{HTTP_HOST} ^gallery\.mypage\.com$ [NC]
RewriteRule ^((?!sub1/).*)$ /sub1/$1 [L,NC]

# For Rewrite
Options +FollowSymLinks

# Turn Rewrite Engine on
RewriteEngine on

# Simple links (news, contact) [/news, /contact]
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1

A:

Try this code in your .htaccess:
# For Rewrite
Options +FollowSymLinks

# Turn Rewrite Engine on
RewriteEngine on

RewriteCond %{HTTP_HOST} ^gallery\.mypage\.com$ [NC]
RewriteRule ^((?!sub1/).*)$ sub1/$1 [L,NC]

# Simple links (news, contact) [/news, /contact]
RewriteCond %{HTTP_HOST} !^gallery\. [NC]
RewriteRule ^([\w-]+)/?$ index.php?page=$1 [L,QSA]

