Page 1 of 1

virtual folders?

Posted: Fri May 14, 2004 10:10 am
by qads
hi,
i am working on a project where users can create their resume/cv, the client wants the script to create a new folder for every CV/resume the users create, which is no problem, but it may be a problem when there are few K users.

so, i was wondering if there is a way to create "virtual folders", which means (in my head heh), that if a user access www.domain.com/cv/[i]username[/i], server would "pretend" the folder does exists, and it would load username's resume, i could find out who the user is by checking out the url typed in, and loading the content from the database :D.

so, how would i go about this? can it be done with a .htaccess file? the hosting is shared so that counts out the mod_rewrite(never used it) etc.

the client is not bothered either way, i just want to be efficient :P.

thanks

Posted: Fri May 14, 2004 10:21 am
by JayBird

Posted: Fri May 14, 2004 6:12 pm
by qads
that is the perfect solution mark but dont think there are many hosts who offer apache2, especially on shared server plan, so i can't use it cos of 'AcceptPathInfo', which is only available on apache2+ :? (my client hast even got a domain yet 8O).


i did try to force apache to accept file names without .ext and parse them (forcetype, addtype), but nope, it dont like that.

any other ideas? :roll:
thanks

Posted: Fri May 14, 2004 6:20 pm
by feyd
what about mod_rewrite then?

Posted: Fri May 14, 2004 6:27 pm
by qads
never used it :?, do i just put it in a htaccess file? cos thats what i did, found it at the link mark posted, in the comments, didnt work....prolly cos i was doing it wrong or the code was wrong.
mod_rewrite wrote: RewriteEngine On
RewriteRule ^/(articles)/(.*)$ /$1.php
[L,PT,E=PATH_INFO:/$2]

Posted: Fri May 14, 2004 6:38 pm
by feyd
I haven't used it yet myself, but it sounds perfect for this situation:
http://httpd.apache.org/docs/mod/mod_rewrite.html

Posted: Fri May 14, 2004 6:40 pm
by qads
big doc 8O, gona have to read it tomrrow or soemthing, working on something atm :P.

thanks :)

Posted: Fri May 14, 2004 6:41 pm
by feyd
alternately.. you may be able to write a specialized 404 handler if you can't get mod_rewrite installed on the host..

Posted: Fri May 14, 2004 6:47 pm
by qads
yea, might just have to do that, if i am right, your talking about having a 404 page which checks what page the user was looking for, and redirects them to the right page after getting the values from the url?

Posted: Fri May 14, 2004 7:11 pm
by feyd
exactly.

Posted: Fri May 14, 2004 7:17 pm
by qads
this might be the only quick (and dirty) way of doing it, i am not sure about the server this site will be hosted on, so i might aswell go with this, atleast its easier to fix if something goes wrong :P.

thanks for idea :D.

Posted: Mon May 17, 2004 4:23 am
by dave420
If the server lets you, you can turn on mod_rewrite in an .htaccess file. It's really, really easy to set up. In your .htaccess file in the top of your document root, put the following:

rewriteengine on
rewriterule /cv(.*) /cv_script.php

that's it! Then, in your cv_script.php file you can look at the $_SERVER["REQUEST_URI"] variable, which will hold the /cv/dave420 URL, as opposed to /cv_script.php. Using the referrer, you can preg_match or split it to retrieve the username.

Of course, this all requires mod_rewrite installed and enabled on your web server.

Try this

Posted: Fri May 28, 2004 3:45 pm
by sandralex

Posted: Sat May 29, 2004 3:26 pm
by qads
got it working :D, it only works on linux, i can live with that :D.

thank you everyone.