Link to home
Start Free TrialLog in
Avatar of bemara57
bemara57

asked on

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.
Avatar of Tintin
Tintin

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?
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?
Avatar of bemara57

ASKER

I do have full control of the server. I am using Apache 1.3
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
Put in your VirtualHost section.
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?
What URL did you specify in your browser?

Is mod_rewrite loaded? (check that it's uncommented in httpd.conf)
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
Does it redirect at all, ie: does it redirect to the wrong URL?
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).
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...

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?
A better way could be writing rewrite rules in .htacess file.