I want my subdomain to point directly to a folder. I have found the following mod_rewrite script to setup this behavior. Unfortunately it does not work.
When I navigate to fish.example.com, the browser displays 404 error with the following message. "The requested URL / was not found on this server."
Do you know why? How can I make it work?
# Internally rewrite <subdomain>.example.com/<URLpath> to example.com/subs/<subdomain/<URLpath>
RewriteEngine on
RewriteCond $1 !^fish/
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /fish/%1/$1 [L]
UPDATE
I have changed the script to the following, but in this case the browser redirects to example.com instead of example.com/fish Do you know why?
RewriteCond $1 !^fish/
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule ^fish/(.*) /fish/%1/$1 [L]