Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,

I have a perl script that runs my online community. It offers them a personal profile page and I would like to make it so that www.mydomain.com/$username will redirect to www.mydomain.com/profile_script.pl?username=$username.

My approach right now is to edit the create account script and upon a creation, it creates the directory mydomain.com/$username and create a index.php file that redirects it the profile script mydomain.com/profile_script?username=$username.

Would this be the best logical approach of carrying out this job? Is there something more efficient or faster?

Thanks for taking your time to read this.

Cheers.

Replies are listed 'Best First'.
Re: Member url's
by andyford (Curate) on Dec 11, 2006 at 18:35 UTC
Re: Member url's
by ahmad (Hermit) on Dec 11, 2006 at 18:37 UTC

    if you have apache web server installed with mod_rewrite module it would be easier to use mod_rewrite rules

    have a look at the following link

    HTH

Re: Member url's
by ambrus (Abbot) on Dec 12, 2006 at 09:39 UTC

    I once used error documents for this kind of thing. In the webserver config file, I set the error document for 404 not found errors in a certain directory to a script that took the full url name and returned the right document. I admit it was a kludge, error documents probably shouldn't be used this way.

    Update: I just noticed that Joost has already said the same in a reply. Sorry.

Re: Member url's
by Anonymous Monk on Dec 11, 2006 at 18:42 UTC
    For help configuring your web server, contact your web server's support line or community.
      ahh, I'm on a shared hosting server as of now. My website is small and only has about 50 members. When I'm able to make some more revenue, I will move to a dedicated and perhaps be able to configure it.

      Sorry that I didn't mention this before.
        If you're on apache, you can add the following to the top-level .htaccess file:
        ErrorDocument 404 /404.cgi
        That will internally redirect any non-found requests to /404.cgi. 404.cgi can then figure out what the original request was by examining $ENV{REQUEST_URI} and show the appropriate information (i.e a valid user page, or a 404 not found page)

        In my experience, this works on lots of shared hosting solutions even if mod_rewrite isn't available.

        if you're on a shared hosting , then you probably have apache with mod_rewrite installed

        and you dont have to configure anything yourself

        you could you use mod_rewrite with .htaccess files

        take a look at the URL i gave to you earlier

        Would cookies be a solution? Does path_info help?

        Gotta run, but just ask if you want clarification on either of these.

        map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
        Tom Melly, pm@tomandlu.co.uk