Page 1 of 1

'virtual' folders - like www.php.net/arrays..

Posted: Fri Aug 23, 2002 4:27 am
by toblo
-At, for example, http://www.php.net you can enter the address
http://www.php.net/arrays, and the site will automatically search for 'arrays' in the manual.

I doubt that they have created folders for every help-section :wink:

Does anybody know how to do this?
I'm making a pretty strange site that is supposed to be able to function as a 'meta community' or just a personal site-organization tool, and it would be great if the user could enter http://www.toblo.net/MyUserName, and immediately see the 'site' of that person (in 'visitor' mode)

Hopefully
/toblo

Posted: Fri Aug 23, 2002 8:16 am
by nielsene
This is one of my favorite tricks in wb programing. I'm not 100% sure why it works, but here's what happening:

The user enters
http://somesite.com/somepage
or
http://somesite.com/folder/somepage

but somepage doesn't exist, before apache throws a fit and a 404, it tries to pass control to a script named "folder" in the second case (maybe to index in the first). The script "folder" (no .php extension) can still look at the whole request_uri and parse out the "somepage" to then use in a databasequery or a redirect, or whatever.

If you need example code let me know and I'll try to dig mine up, but I'm going to be away for a few hours now...

Posted: Fri Aug 23, 2002 8:41 am
by fatalcure

Cool! - Some problems, though

Posted: Fri Aug 23, 2002 8:53 am
by toblo
Sounds perfect for me, but I'm still getting the same ol' Apache error message

The file "folder" contains this:

<?

print "I DON'T know what you're talking about..";

?>

Where is this file supposed to be located, BTW?

Maybe I should have mentioned that I have no control over the server - my site is hosted at http://www.f2s.com, so I can only access my own root directory.. :/

Do you think it's possible to use this technique under those conditions?..

Hope against all hope..
/Toblo

Posted: Fri Aug 23, 2002 8:58 am
by fatalcure
if your server is unix, you can just upload the .htaccess to the root and test it out.

so if your root is /home/user/ and your file name was folder
you'd have an .htaccess in that folder with:
<Files folder>
ForceType application/x-httpd-php
</Files>

if you created another REAL folder, lets say /home/user/folder2/
you would also need to have a .htaccess with the files that need to be parsed as php

Interesting

Posted: Fri Aug 23, 2002 9:23 am
by toblo
fatalcure>> Thanks - I'll check that out, even though UNIX stuff is still a voodoo-thingie to me ;)

If I can get that other way to work, though, it would be more what I had in mind - otherwise I'd have to add stuff to the .htaccess file every time a new user registered, right?

Love your site-design, BTW! - envious of that spinning V/A logo

Bountiful holiday-wishes
/toblo

Posted: Fri Aug 23, 2002 9:53 am
by llimllib
no, if you can get it to work with a .htaccess, you'll never have to change it.

Posted: Fri Aug 23, 2002 10:02 am
by nielsene
SourceForge.net uses this all over the place /projects/projectname, /users/username, /foundry/foundryname ,etc. I've linked the applicable files out of the sf-genericinst package.

.htaccess
projects

Of course most of the magic is done in some of the earlier includes, specifically
logger.php

Posted: Fri Aug 23, 2002 10:28 am
by jason
Actually, PHP.net goes over how they do it, and even give you their code:

http://www.php.net/urlhowto.php

Posted: Fri Aug 23, 2002 11:19 am
by hob_goblin
Damnit jason :( I was scrolling down and checking that no one said it :(... Yeah, php.net explains most of the stuff they do.

niiiiice :)

Posted: Fri Aug 23, 2002 11:58 am
by toblo
WOW! I actually got it working - in spite of my UNIX-fear :)

This is great, guys! -Thanks a big bunch!

Mental note: MUST NOT SPEND WEEKEND CODING SITE!

Hope y'all are going to have a nice weekend, and that you'll register at the site I'm doing when (and if) it's good enough for public consumption :)

/toblo