Dynamic subdominio with htaccess and php

Asked

Viewed 869 times

1

I’m racking my brain. I need to create dynamic subdominios for each user who registers on my site (e.g., user1.dominio.com.br, usuario2.dominio.com.br, usuario3.dominio.com.br) without having to create one by one in the Cpanel.

I know this has to do with wildcard created the dns entry *.meudominio.com.br but it doesn’t work.

I want to do as in this example: http://thewallchat.com/

I tried this tutorial: https://www.9lessons.info/2016/03/how-to-create-dynamic-subdomains-using-php-and-htaccess.html but it didn’t work because Cpanel doesn’t let you create dns with @.

who can help me I appreciate.

1 answer

1

  • Felipe, I believe what he wants is something dynamic: a user has registered on the site... soon he will have a subdomain... felipe.dominio.com.br. At least that’s what I understood.

  • He even put the link to the example: http://andrei.thewallchat.com/

  • That’s right, in this tutorial explains exactly how to do this in cPanel... next it will be able to access any dynamic sub-domain (e.g., teste1.thewallchat.com or test11111.thewallchat.com... etc)

  • Cool Felipe! Had not understood the tutorial. I expected something with . htaccess. =)

  • Thanks Felipe managed to do, now how do I make each user have a folder? For example, user Felipe has a folder with this name on my server and when accessing Felipe.dominio.com.br the files of this user’s folder are loaded as if they were the root folder of the server. .

  • Well, I would do something in PHP ex: <? php $dominio = $_SERVER['REQUEST_URI']; if($dominio = 'Felipe.dominio.com.br'){ include('/folder/do/Felipe.dominio.com.br'); } if($dominio = 'test.dominio.com.br'){ include('/folder/do/test.dominio.com.br'); } ? > !

Show 1 more comment

Browser other questions tagged

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