V
V
Vahe2016-01-06 15:54:53
Apache HTTP Server
Vahe, 2016-01-06 15:54:53

.htaccess rewrite subdomain to directory?

Is it possible to use .htaccess to rewrite a subdomain into a directory?
Example: sub.domain.com shows content domain.com/subdomains/sub
rewritten to .htaccess but doesn't work

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ http://domain.com/subdomains/%1/$1 [L,NC,QSA]

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question