How to redirect Subdominio to specific folder from using . htaccess

Asked

Viewed 245 times

0

I created the subdomains using wildcard I would like to understand how I can solve the following problem with . htaccess:

usuario.site.com.br -> (Aponta para pasta Usuário)
fulano.site.com.br  -> (Aponta para pasta Fulano)
bug.site.com.br     -> (Aponta para pasta Bug)

And which other sub-domains I would add . htaccess would point to by modifying dynamically. If the folder did not exist then it would be pointed to the site.com.br

1 answer

0

I got Galera, with this great article here: https://www.it-swarm.dev/pt/php/crie-subdominios-em-tempo-real-com-o-.htaccess-php/957812701/

http://www.webmasterworld.com/Apache/3163397.htm

using it in . HTACCESS

RewriteCond %{ENV:REDIRECT_SUBDOMAIN} ="" 
RewriteCond %{HTTP_Host} ^([a-z0-9][-a-z0-9]+)\.domain\.com\.?(:80)?$ [NC] 
RewriteCond %{DOCUMENT_ROOT}/%1 -d 
RewriteRule ^(.*) %1/$1 [E=SUBDOMAIN:%1,L] 
RewriteRule ^ - [E=SUBDOMAIN:%{ENV:REDIRECT_SUBDOMAIN},L]

Extra Comment: It’s annoying when they have user who does not know how to answer and dimmed the classification of the question... Finally I hope to have helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.