Solved

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

Posted on 2006-11-20
16
3,960 Views
Last Modified: 2013-12-25
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.
0
Comment
Question by:bemara57
  • 4
  • 4
  • 3
  • +2
16 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 17984776
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17985737
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
 

Author Comment

by:bemara57
ID: 17987040
I do have full control of the server. I am using Apache 1.3
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
ID: 17987990
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
 

Author Comment

by:bemara57
ID: 17988201
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
 
LVL 48

Expert Comment

by:Tintin
ID: 17989803
Put in your VirtualHost section.
0
 

Author Comment

by:bemara57
ID: 17990104
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 48

Expert Comment

by:Tintin
ID: 17990249
What URL did you specify in your browser?

Is mod_rewrite loaded? (check that it's uncommented in httpd.conf)
0
 

Author Comment

by:bemara57
ID: 17991095
0
 
LVL 48

Expert Comment

by:Tintin
ID: 17991357
Does it redirect at all, ie: does it redirect to the wrong URL?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17993897
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
 
LVL 17

Expert Comment

by:mjcoyne
ID: 18206378
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
 
LVL 17

Expert Comment

by:mjcoyne
ID: 19344363
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
 
LVL 6

Expert Comment

by:nitinsawhney
ID: 19989897
A better way could be writing rewrite rules in .htacess file.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reading data with a bash script from a CSV file based in uniqueID 15 48
Help in WHSCRIPT 9 48
Update a File not in all folders 2 43
Facebook React and SyntheticEvents 6 50
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now