Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 650361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:02:40+00:00 2026-05-13T22:02:40+00:00

I want to create sub-domains using PHP on the fly. Suppose a user registers

  • 0

I want to create sub-domains using PHP on the fly. Suppose a user registers himself as a name “ABC”. Then I want to create a sub-domain named ‘ABC.mydomain.com’ automatically by PHP. I’m using a linux based server.

Would anyone point me to the right direction?

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:02:41+00:00Added an answer on May 13, 2026 at 10:02 pm

    You should be aware that this is easily done using wildcard DNS records. This way:

    • you do not have to register each user to your DNS server.
    • your DNS A-record may contain as few as 1 record: e.g *.mydomain.com -> 12.34.56.78
    • your web server at 12.34.56.78 have to be configured to accept wildcard

    In your server-side scripts, you dynamically resolve “abc.mydomain.com” on your controller/routing code by checking if abc is an existing active username, sample code below:

    <?php
    
    // Note that I am using SERVER_NAME vs HTTP_HOST, 
    //    but for additional safety also check your httpd.conf
    list($user, $domain) = split("\.", $_SERVER['SERVER_NAME'], 2);
    
    // check if domain is correct, 
    //    or you can leave this part if the web server checks this already
    if ($domain === "mydomain.com") {
    
        // here, you verify $user if existent/active 
        // and reroute or render the page depending on request params 
        // ...
    
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a cookie from one domain once the user is registered
I want to redirect a domain name : http://www.newdomain.com to http://sub.maindomain.com I have edited
Is it possible to create subdomains dynamically on server using php script? I want
Hallo all. i want to create a .htaccess file if i type subdomain.domain.com can
i want to create sub menu for a BB application when i click on
I want to create a transaction, writing some data in a sub-transaction, reading the
I want create wordpress website into which I want create user management... That means
I want to make an app which allows to create a table by using
I am using mvc3 and I want to create an API with the site.
I want to create folders on the fly, but make it seem like I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.