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

前端 未结 12 1182
暖寄归人
暖寄归人 2020-11-22 13:43

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

12条回答
  •  误落风尘
    2020-11-22 14:13

    Don't fuss around with .htaccess files when you can use Apache mass virtual hosting.

    From the documentation:

    #include part of the server name in the filenames VirtualDocumentRoot /www/hosts/%2/docs

    In a way it's the reverse of your question: every 'subdomain' is a user. If the user does not exist, you get an 404.

    The only drawback is that the environment variable DOCUMENT_ROOT is not correctly set to the used subdirectory, but the default document_root in de htconfig.

提交回复
热议问题