RewriteEngine on
RewriteBase /
# rewrite <subdomain>.example.com/<path> to example.com/<subdomain>/<path>
#
# Skip rewrite if no hostname or if subdomain is www
rewriteCond %{HTTP_HOST} .
rewriteCond %{HTTP_HOST}!^www\. [NC]
# Extract (required) subdomain (%1), and first path element (%3), discard port number if present (%2)
rewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.zaxy\.org(:80)?<>/([^/]*) [NC]
# rewrite only when subdomain not equal to first path element (prevents mod_rewrite recursion)
rewriteCond %1<>%3!^(.*)<>\1$ [NC]
# rewrite to /subdomain/path
rewriteRule ^(.*) /%1/$1 [L]
I tried that code above, and I get 500 error.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com [NC]
RewriteRule ^(.*)
http://www.yourdomain.com/$1 [L,R=301]
I tried that code, and I believe this one worked, but it redirected the browser to the folder location, and I don't want that. I want anysubdomain.mydomain.com to READ from mydomain.com/subdomain/ , not redirect. I could do that with a simple normal 301. I tried replacing the
RewriteRule ^(.*)
http://www.yourdomain.com/$1 [L,R=301]
with
RewriteRule ^(.*) /home/mydomain/public_html/$1/ but it didn't do any good. Still 500 error.