My webpage bookmarks are extra long.. Can a CGI help shorten my links??

If someone would want to go to an exact pageon my website, they'd have to put a lot of parameters in the link to get there. For example, this is just to get to my home page:

http://mydomain.com/cgi-bin/livescript.bat?co_id=LU/&LOC_NO=001&reqr_type=O&reqr_id=NEW%20CUSTOMER&AUTH_ID=&request_id=index

Most of my webpages share one part of the address all the time: &co_id=LU/&LOC_NO=001&reqr_type=O&reqr_id=NEW%20CUSTOMER&AUTH_ID=

Is there a way where I can create a script that I can give someone my link as http://mydomain.com/cgi-bin/rewrite.cgi?request_id=index

What rewrite.cgi will do is transform that to the first link above, which is the real one. How would you do this? Any help is greatly appreciated.
bemara57Asked:
Who is Participating?
 
ahoffmannCommented:
then I'd use mod_rewrite, something like:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/cgi-bin/rewrite.cgi
RewriteRule ^/cgi-bin/rewrite.cgi?(.*)$ /cgi-bin/livescript.bat?co_id=LU/&LOC_NO=001&reqr_type=O&reqr_id=NEW%20CUSTOMER&AUTH_ID=&$1
0
 
TintinCommented:
Do you have control of the webserver, as this is a better job for the webserver to perform?

If you do want to use a CGI program, how many different parameters do you want it to accept?

In your example, you have

rewrite.cgi?request_id=index

What other values for request_id can there be?
0
 
ahoffmannCommented:
yes a cgi can help, as Tintin explained, but I'd use the web server to do the rewriting. Which web server do you use?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
bemara57Author Commented:
I do have full control of the server. I am using Apache 1.3
0
 
bemara57Author Commented:
Should I put this in my VirtualHost section because I am using virtualhosting. Or should I put this in the <Directory> section for the location of the DocumentRoot?
0
 
TintinCommented:
Put in your VirtualHost section.
0
 
bemara57Author Commented:
It says page cannot be found. Doesn't look like its doing any rewriting. Copied exactly what you wrote up there. Even restarted apache. Any other settings that I have to turn on?
0
 
TintinCommented:
What URL did you specify in your browser?

Is mod_rewrite loaded? (check that it's uncommented in httpd.conf)
0
 
bemara57Author Commented:
Yup my mod_rewrite is loaded. I am putting this in my browser:

http://mydomain.com/cgi-bin/rewrite.cgi?request_id=index

which should reqrite it to this but doesn't:

http://mydomain.com/cgi-bin/livescript.bat?co_id=LU/&LOC_NO=001&reqr_type=O&reqr_id=NEW%20CUSTOMER&AUTH_ID=&request_id=index
0
 
TintinCommented:
Does it redirect at all, ie: does it redirect to the wrong URL?
0
 
ahoffmannCommented:
silly question: you added exactly 3 lines each beginning with Rewrite ?
There're no line breaks in my posted configuration lines.

If it still fails, please check your error_log and access_log, and post messages if any (according this request).
0
 
mjcoyneCommented:
As written, I think it's looking for a script called rewrite.cgi, which I assume you don't have, hence the page not found errors...

0
 
mjcoyneCommented:
I think ahoffmann's suggestion to use mod_rewrite was the correct approach and, after a bit of tweaking, likely resulted in the probelm being solved and thus the question abandoned.  Shouldn't he get the points in the absence of any comment from the questioner?
0
 
nitinsawhneyCommented:
A better way could be writing rewrite rules in .htacess file.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.