Gossamer Forum
Home : General : Perl Programming :

http Redirect

Quote Reply
http Redirect
For a URL referring to a dbman-address I would like to make available a redirection script in order to simplify the URL.

The only parameter necessary to be provided is the Userid.

So, instead of http://www.mydomain.com/db.cgi?db=default&uid=default&view_records=1&ww=1&Userid=me

I would like to have a script so that the URL can be short like this:
http://www.mydomain/redirect.cgi?me.

How would this script look like ?

Is there a way to get it even shorter, say http://www.mydomain.com/me (server redirection is not available) ? If not what's the shortest possible URL ?

Georg
Quote Reply
Re: http Redirect In reply to
The hypernews web forums software does this type of redirection using a CGI wrapper. Basically, what you do is use static variables in the wrapper to redirect the user to the incoming query variable. As an example:
Code:
#!/usr/local/bin/perl
$UserId = $ENV{'QUERY_STRING'};
$db = "default";
$uid = "default";
$view_records = 1;
$ww = 1;
$url = http://www.mydomain.com/db.cgi

print "Location: $url?$db&$uid&$view_records&$ww&$UserId";
I am not sure about the print line for the location, this can vary depending on the web server. Using the hypernews example, the would use a url such as http://www.mysite.com/cgi-bin/HyperNews/get.cgi/foobar.html

The get.cgi actually pulls out the foorbar.html and displays the forum for foobar. This can be shortened even further to /get/foobar.html, but you would have to make changes to the server to allow "get" to run as a program. The problem with doing this in your example is that you would have to create individual scripts/wrappers for each user. Not sure if that is the sort of overhead you would want. You could however do it the hypernews way, and make something like http://www.mydomain.com/redirect/me or something like that, but again, you would have to reconfigure the web server to allow "redirect" to run as a script.

Hope this helps.


------------------
Fred Hirsch
Web Consultant & Programmer