DEV Community

Fred
Fred

Posted on

 

Answer: How to let PHP to create subdomain automatically for each user?

Create Dynamic Subdomains using PHP and Htaccess

(1) Root .htaccess

This file is redirection http://www.yourwebsite.com to http://yourwebsite.com for home page use. All of the subdomain redirection to yourwebsite_folder

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.yourwebsite.com
RewriteRule (.*) http://yourwebsite.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^yourwebsite\.com $
RewriteCond %{REQUEST_URI} !^/yourwebsite_folder/
RewriteRule (.*) /yourwebsite_folder/$1

RewriteCond %{HTTP_HOST} ^(^.*)\.yourwebsite.com

Top comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.