creating subdomains using php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sharma

    #1

    creating subdomains using php

    Hi all,

    I have a site called www.example.com. I would like to offer free hoting
    to the people and offer a site with their username like this.
    www.username.example.com. Please can any one here tell me how to
    accomplish this using php ?

    Thanks,
    sharma

  • Dani CS

    #2
    Re: creating subdomains using php

    sharma wrote:[color=blue]
    > Hi all,
    >
    > I have a site called www.example.com. I would like to offer free hoting
    > to the people and offer a site with their username like this.
    > www.username.example.com. Please can any one here tell me how to
    > accomplish this using php ?[/color]

    This is not done with PHP.

    Apache can handle dynamic virtual hosts, which is what you want. Please
    check <http://httpd.apache.or g/docs/vhosts/>.

    [color=blue]
    >
    > Thanks,
    > sharma
    >[/color]

    Comment

    • sharma

      #3
      Re: creating subdomains using php

      Hi Dani,

      When a user submits the registration form , how did this virtual host
      create from php script? Any idea...

      Thanks,
      sharma

      Comment

      • Dani CS

        #4
        Re: creating subdomains using php

        sharma wrote:[color=blue]
        > Hi Dani,
        >
        > When a user submits the registration form , how did this virtual host
        > create from php script? Any idea...[/color]

        Read the documentation about mass dynamic virtual hosts and then figure
        it out.

        It involves creating a directory (php: mkdir()) and probably assigning
        it the proper permissions (php: chmod()). Good luck!

        Taken from the Apache docs:

        <quote src="http://httpd.apache.or g/docs/vhosts/mass.html#motiv ation">
        2. Adding virtual hosts is simply a matter of creating the
        appropriate directories in the filesystem and entries in the DNS - you
        don't need to reconfigure or restart Apache.
        </quote>


        About the DNS thing, I can't help you. Depending on your case it might
        even be unnecessary. Anyways, this is not the best newsgroup for that
        matter.
        [color=blue]
        >
        > Thanks,
        > sharma
        >[/color]

        Comment

        • R. Rajesh Jeba Anbiah

          #5
          Re: creating subdomains using php

          sharma wrote:[color=blue]
          > Hi Dani,
          >
          > When a user submits the registration form , how did this virtual host
          > create from php script? Any idea...[/color]

          Usually, they won't. There are lots of way to do it with virtual
          host directive. Most simplest thing is to use ServerAlias...

          <VirtualHost *>
          ....
          ServerName example.com
          ServerAlias *.example.com
          ....
          </VirtualHost>

          Now, anything like a.example.com or b.example.com will be served
          with example.com's content.

          Now, you actually want to serve different pages for a.example.com
          and b.example.com. So, you have to see what is the requested subdomain
          (whether it's "a" or "b"). In PHP, you can see it through $_SERVER
          variables or may again use mod_rewrite to send the subdomain request to
          a php file as query string like index.php?subdo main=%1 or so.

          So, you basically have only one index.php file, but will have
          different requests coming (via subdomain). index.php can serve
          different pages depending upon the request.

          --
          <?php echo 'Just another PHP saint'; ?>
          Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

          Comment

          • ^demon

            #6
            Re: creating subdomains using php

            You would need to find what the required text in httpd.conf is, and
            then have your script write to httpd.conf the required value. Seems
            quite insecure though.

            Comment

            • R. Rajesh Jeba Anbiah

              #7
              Re: creating subdomains using php

              ^demon wrote:[color=blue]
              > You would need to find what the required text in httpd.conf is, and
              > then have your script write to httpd.conf the required value. Seems
              > quite insecure though.[/color]

              Sorry, I don't understand what are you talking about. Could you be
              more specific?

              --
              <?php echo 'Just another PHP saint'; ?>
              Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

              Comment

              Working...