Dynamic user data, all using the same pages

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
dyonak
Forum Commoner
Posts: 56
Joined: Wed Jun 22, 2005 10:22 am
Location: Minneapolis, MN
Contact:

Dynamic user data, all using the same pages

Post by dyonak »

Ok so I have a personal site where I have a blog and other database polled information displayed. Out of curiousity and a bit of nudging I would like to be able to have a site for my little lady to be displayed at http://www.mypage.com/hername. I want it to use all the same files I use for my page for easier maintainability. Here's what I've got so far:


main (folder)
--hername (folder)
----index.php (includes the main folder's index.php and sends a user name SESSION variable along with it)
--index.php
--blog.php
--otherstuff.php

Now this works great for the index.php page but not as well for the blog.php page. I would have to make a dummy page for each real page I wanted to include in her folder which seems silly. It wouldn't be so bad if it was as easy as this example looks but the blog page alone has about 4 other pages that go along with it for commenting, adding, and deleting blogs. Add that up with all the other pages I've got for my site and it's quite the chore. Most importantly, to me, though is the fact that I just don't feel like that would be the best solution. Someone's got to have a much more elegant way of doing this. I'm probably overthinking the whole thing. Thanks if advance for the input.
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

Use an .htaccess file which redirects all references to the folder /hername to a special handling page with user=hername as the parameter. This page will then set appropriate session data (ie: log her in) and redirect to the requested page (blog.php, etc.).
dyonak
Forum Commoner
Posts: 56
Joined: Wed Jun 22, 2005 10:22 am
Location: Minneapolis, MN
Contact:

Post by dyonak »

Set the parameter how, through a GET request I assume? I'll try looking around on google for htaccess info as well, I've never messed with that stuff.

Thanks man!
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I would just set up a VD for "hername" that points to the same web folder as the root.

you could then use php to check if it's going throught the root or "hername" and set vars accordingly.

by doing that, you wouldn't have to copy anything, just check for the existance of "hername" in the URL.
dyonak
Forum Commoner
Posts: 56
Joined: Wed Jun 22, 2005 10:22 am
Location: Minneapolis, MN
Contact:

Post by dyonak »

VDs from what I've googled are IIS only and htaccess commands will allow me to, in essence, do the same thing with my Apache server, is this correct?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

dyonak wrote:VDs from what I've googled are IIS only and htaccess commands will allow me to, in essence, do the same thing with my Apache server, is this correct?
Virtual Direcotries can also be set up using Apache.... they're just not called Virtual Directories :) You're looking for "alias" ;)
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

dyonak wrote:VDs from what I've googled are IIS only and htaccess commands will allow me to, in essence, do the same thing with my Apache server, is this correct?
You can set them up in apache too. You need to do it through httpd.conf though, not .htaccess
Post Reply