How do I force .htaccess to direct a subdomain into a folder?

1

I do not understand much of apache's .htaccess, so I would like to ask colleagues if it is possible what I will explain, I have a domain: mycard.com.br and a subdomain teste.mycard.com.br the folder domain / home / mycard / html already the subdomain folder is / home / mycard / html / subdomains / test.

I wanted the user not to enter the subdomain by the link link but by link

If he type: link or link

I could put a redirection file in these folders, but if he types link it accesses and this I did not want to

He would be redirected to link

Is it possible to do this by .htaccess?

The ideal would be to create the subdomains at the same level as the html folder, but I do not have access to the apache vhosts, the server locaweb creates the subdomain folder inside html

    
asked by anonymous 21.11.2017 / 20:36

1 answer

1
RewriteEngine On

# http://mycard.com.br/subdominios  -->  http://mycard.com.br
RewriteCond %{HTTP_HOST} ^mycard\.com\.br$ [NC]
RewriteRule ^subdominios/?$ / [R=301,NC,L]

# http://mycard.com.br/subdominios/nome  -->  http://nome.mycard.com.br
# http://mycard.com.br/subdominios/nome/exemplo.html  -->  http://nome.mycard.com.br/exemplo.html
RewriteCond %{HTTP_HOST} ^mycard\.com\.br$ [NC]
RewriteRule ^subdominios/([^/]+)(/.*)? http://$1.mycard.com.br$2 [R=302,NC,L]
    
21.11.2017 / 23:59