How do I create subdomain like http://user.mywebsite.com ? Do i have to access htaccess somehow? Is it actually simply possible to create it via pure php code or I need to u
This can be achieved in .htaccess
provided your server is configured to allow wildcard subdomains. I achieved that in JustHost by creating a subomain manually named *
and specifying a folder called subdomains as the document root for wildcard subdomains. Add this to your .htaccess
file:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.website\.com$
RewriteCond %{HTTP_HOST} ^(\w+)\.website\.com$
RewriteCond %{REQUEST_URI}:%1 !^/([^/]+)/([^:]*):\1
RewriteRule ^(.*)$ /%1/$1 [QSA]
Finally, create a folder for your subdomain and place the subdomains files.