SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A concept like blogspot! Subfolder management in php. Possible this way?

    Well, I am thinking to structure a site with each user having their own space, like rudy.domain.com, spike.domain.com, etc.

    Now, if I have 900 users, with 900 subdomains, do I need to have the same files 900 times? Say the index.php inside each of the subfolders will have the same code, client side content of which will change depending on the login details.

    Like can I have an index.php somewhere, and when each of the folders will load, the same index.php (and all other files) will be called. Users will still see they are in their own space, say in vinnie.domain.com/index.php but that index.php will be physically located elsewhere.

    Is that possible, or I will have to upload the same index.php 900 times in each sub folders?

    Thought this is something that needs expert's advice, so I'm here.

    NB. If this question arises in someone's mind, in CP we can create subdomains thro' a script, that's not an issue.

  2. #2
    SitePoint Zealot
    Join Date
    Oct 2007
    Location
    In the blogosphere
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You wouldn't even need that. All you'd need is wildcard DNS setup and a wee bit of php coding
    bLueFrogX's Blog - Random Ramblings of a NEET Techie ★

  3. #3
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    blue, could you please put a few more lines to let me digest better your wisdom ?

    Edit:

    Hmmm ... I think that the wildcard DNS was the keyword here. It seems that all what I need is just a few lines in my .htaccess that will fetch data from the public_html/ for whatever called from it's subdomain. Like, on doing http://rudy.domain.com/index.php I will get the contents of http://www.domain.om/index.php and by doing http://vinnie.domain.com/photos/trip-to-paris.php I will basically get the contents of http://www.domain.com/photos/trip-to-paris.php, while the user will still see that they are in their respective subdomains.


    Edit:

    Well, problem solved. Blue's reply was short by to the point. Did some googling, and finally send a support ticket to my host. Seems it's a simple thing. Need a wildcard DNS, without any wee bit of php coding.
    Last edited by kigoobe; Oct 26, 2007 at 04:21.

  4. #4
    Team SitePoint santouras's Avatar
    Join Date
    Jul 2006
    Location
    planet earth
    Posts
    276
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    The wee bit of php coding comes in associating the wildcard domain with a particular user
    my utility belt tells me its to the bar batman

    read the manual then google it then do a search THEN post....

  5. #5
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, there's a trick here. any.domain.com/folder/any.php can be pointed to domain.com/folder/same.php with wildcard DNS, and there I can give users a page depending on his login information, so that's fine.

    However, If I have two users, nathon and graham, each with respective domains - nathon.domain.com and graham.domain.com, each one will see their own home page depending on their login information.

    The catch is, if nathon wants to see the home page of graham. As, by doing graham.domain.com, he is getting pointed to / and there depending on the login information, he is seeing his own home page. !!!

    It will be possible if I can get the domain, graham.domain.com, as then I could compare the username graham with login information, and comparing the two I could offer the proper page.

    Hmmm ...

  6. #6
    Team SitePoint santouras's Avatar
    Join Date
    Jul 2006
    Location
    planet earth
    Posts
    276
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    have a look at $_SERVER['HTTP_HOST'] and $_SERVER['SERVER_NAME'] to see if you're getting the subdomain information through. That way you can check which set of information to display.

    Doing a phpinfo(); when you're running on these wildcards is really handy as you can see what variables you can use to detect the wildcards.
    my utility belt tells me its to the bar batman

    read the manual then google it then do a search THEN post....

  7. #7
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah ... I just hope that the domain propagation won't take long !!! for the moment I don't see much ...

  8. #8
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,103
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I have done something similar with mod_rewrite

    just set up a subdirectory like graham

    then when someone goes to graham.mydomain.com it will just redirect them to mydomain.com/graham automatically, then you will not need to set up subdomains and wait for the dns update.

    google for mod_rewrite to rewrite for you particular application.

  9. #9
    SitePoint Zealot
    Join Date
    Oct 2007
    Location
    In the blogosphere
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I still think wildcard DNS would be a better option as it would appear as if the had their own subdomain, instead of a directory. Also, if you create a subdirectory, you'd either have to copy over index.php a gazillion times or at least link it symbolically.

    It is slightly more resource intensive to do customization via PHP, but hey, nothing's free
    bLueFrogX's Blog - Random Ramblings of a NEET Techie ★

  10. #10
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,103
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The way I did it was to create the directory with an index.php that included a master index.php (since master.php was included in every dir it is a cinche to modify it sitewise) and with global variables, determined the mame of my directory and then get all of the information for "graham" displayed on the page.

    likewise if graham were logged in, he would see the options for editing his page.

    I did this because I had (still dont) no idea what wildcard DNS was and did not know how to automatically set up a subdomain with php.

    six of one or a half dozen of another ;-) I usually go about things the hard way because i dont know all of the ways.

    thanks, i will look into the wildcard thing just to understand it.
    What I lack in acuracy I make up for in misteaks


Bookmarks

Posting Permissions

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