Reputation: 483
I have a site example.com
whose files are at /path/to/example/
It has subdomains subdomain.example.com
whose files are at /path/to/example/subdomain/
How can I serve these files using .htaccess
without redirection?
I tried
RewriteCond %{HTTP_HOST} ^subdomain.example.com
RewriteRule ^(.*)$ http://example.com/subdomain/$1 [L]
but this redirects users to a new page.
I also tried
RewriteCond %{HTTP_HOST} ^subdomain.example.com
RewriteRule ^(.*)$ /subdomain/$1 [L]
but this gives a server error.
Upvotes: 1
Views: 39
Reputation: 785098
Try this rule:
RewriteCond %{HTTP_HOST} =subdomain.example.com
RewriteRule !^subdomain/ subdomain%{REQUEST_URI} [L,NC]
Upvotes: 1