Results 1 to 4 of 4
  1. #1

    Need help with creating subdomains in PHP

    I've hired a programmer to create a site for me and we have run into a problem with subdomains. When someone signs up to the site, it should automatically create a subdomain for them. Heres the problem.

    We have successfully created subdomains using a php script. But inside the created subdomains, we need to move the file called index.php. We tried moving the file index.php inside the subdomain using php coding, but we recieve permission denied.

    Also we tried to change subdomain permission using chmod function in php, but it throws operation not supported error.

    Whatever folder created on your server through the php coding folder the owner name is "username". But whatever folder created on our server through php coding the folder owner name is "Apache". Also we created folders on other servers through php coding the folder owner name is "Apache". But in your server only owner name is "username". Please clarify
    The solution my php programmer wants me to do is add command "umask 0000" to .bash_profile for the username, but my server provider is saying that will cause problems.

    Any help would be appreciated. Willing to pay for your time.

  2. #2
    What is the file structure that you're using for this? I assume it something along the lines of...

    so on...

    Is that the basic idea? If so, you might consider creating a copy of your index.php file that is in a 0777 chmod'd folder, and then try copying -that- elsewhere. However, if (like it should be) your PHP is configured to not allow that sort of movement, you could create a shell script above all of your sub directories that can be called within your PHP files to do the copying.

    Again though, this allll depends on your server configurations, etc. Let me know if this gets you anywhere, hope it helps.

  3. #3
    I assume you're trying to do something what blog services do when new users sign up - assign a subdomain to that user or something along those lines.

    Anyway, you can mention this to your php programmer and he can probably work his way out further - create a catch-all record for your domain (in domain zone file, your hosting provider can do that for you). Then if subdomain isn't created, all requests will be redirected to Then you can use mod_rewrite to find out which subdomain was actually requested.

    So basically, when someone signs up - create a record in database table (or wherever you store your data) for a subdomain that person is assigned to. When they try to access and if my subdomain doesn't exist - that request will be redirected to You can then "capture" which subdomain was requested (my) and check that subdomain against database, serve appropriate files or whatever you need to do. I hope I explained it properly and I hope this helps.

    You don't need to copy any files for new subdomains, you use the exact same code to serve for each request / subdomain.

  4. #4
    If stored in a dynamic page or directory you can check the username against the database, if the name isn't found the page can be redirected to your standard/non-users page. For a directory this works the same way.
    Best Hosting Experiences: Voxtreme.Com (Shared Reseller / 5yrs / Former), Serverpoint.Com (Dedicated & VPS / 13+ yrs / Current)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts