How do I make subdomains point to a subfolder with .htaccess?

How do i convert to –>
using .htaccess
tricking the browser and person into thinking they have an actual subdomain

You can try something like this:

# if requested subdomain is not "www"
RewriteCond %{HTTP_HOST} !^(www\\.)?example\\.com [NC]
# and we have not already rewritten this request to the subdomain's subfolder
RewriteCond %{THE_REQUEST} !/folder/.
# extract requested subdomain to %2
RewriteCond %{HTTP_HOST} ^(www\\.)?([^.]+)\\.example\\.com
# rewrite the request to the subdomain's subfolder
RewriteRule (.*) /folder/%2/$1 [L]

I tried it and it doesn’t work.

I got this code though.

RewriteEngine On
Options Indexes FollowSymlinks Multiviews
RewriteBase /
RewriteCond %{HTTP_HOST}
RewriteCond %{REQUEST_URI} !forum/
RewriteRule ^(.*)$$1 [L]

What it does is that it redirects to
But by redirecting the url changes, is there a way I can use masking or something like that so url doesn’t redirect?

NO! That is a security issue (making an external redirect) so it is a design feature that you WILL have the new URL displayed.



So what does wordpress MU do then? It doesn’t exactly edit the .htaccess file as it works with shared hosting.

I found a post here which helps solve the problem redirects to
and it works so much that I can even get

Do you know how I found this page in less than 5 minutes?
I used this useful .htaccess search engine and then I searched for [URL=“”]subdomain.

The results are amazing!


Redirection is easy to hide (the change of URI) but a redirection to a different server (a subdomain IS a different server) must be displayed to the visitor. You asked for a hidden redirection to a different domain but showed both types in your examples. redirects to
and it works so much that I can even get…5642a567d3e390 => MUST be displayed => can be hidden

As usual, it’s all in the specification.